CMake Cookbook by Radovan Bast

CMake Cookbook by Radovan Bast

Author:Radovan Bast
Language: eng
Format: epub, mobi
Tags: COM051440 - COMPUTERS / Software Development and Engineering / Tools, COM010000 - COMPUTERS / Compilers, COM051230 - COMPUTERS / Software Development and Engineering / General
Publisher: Packt
Published: 2018-09-26T06:27:16+00:00


message(STATUS "working C compile flag: ${working_compile_flag}")

And we try a list of C++ flags:

set_compiler_flag(

working_compile_flag CXX REQUIRED

"-foo" # this should fail

"-g" # this should work with GNU, Intel, PGI

"/RTCcsu" # this should work with MSVC

)

message(STATUS "working CXX compile flag: ${working_compile_flag}")

Now, we can configure the project and verify the output. Only the relevant output is shown and the output may differ depending on the compiler:

$ mkdir -p build

$ cd build

$ cmake ..

-- ...

-- Performing Test _flag_works

-- Performing Test _flag_works - Failed

-- Performing Test _flag_works

-- Performing Test _flag_works - Failed

-- Performing Test _flag_works

-- Performing Test _flag_works - Failed

-- Performing Test _flag_works

-- Performing Test _flag_works - Success

-- working C compile flag: -Wall

-- Performing Test _flag_works

-- Performing Test _flag_works - Failed

-- Performing Test _flag_works

-- Performing Test _flag_works - Success

-- working CXX compile flag: -g

-- ...



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.