[CMake] compiler defines for sub projects
Keith Gardner
kgardner at zebraimaging.com
Fri Apr 5 15:02:10 EDT 2013
If you want to have all of the sub directories to have the defines present, you could use ADD_DEFINITIONS().
option(FOO_OPTION "enable foo" OFF)
option(BAR_OPTION "enable bar" OFF)
if(FOO_OPTION)
add_definitions("-DFOO_X" )
elseif(BAR_OPTION)
add_definitions("-DFOO_Y")
else()
add_definitions("-DOTHER")
endif()
-----Original Message-----
From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of Olaf Peter
Sent: Friday, April 05, 2013 12:58 PM
To: cmake at cmake.org
Subject: [CMake] compiler defines for sub projects
Hello,
is it possible to inherit compiler defines for sub projects in sub directories?
I have a library project which can be configured at compile time using preprocessor defines (cmake option)
option(FOO_OPTION "enable foo" OFF)
option(BAR_OPTION "enable bar" OFF)
if(FOO_OPTION)
set_target_properties(my_lib PROPERTIES COMPILE_DEFINITIONS "FOO_X" )
elseif(BAR_OPTION)
set_target_properties(my_lib PROPERTIES COMPILE_DEFINITIONS "FOO_Y")
else()
set_target_properties(my_lib PROPERTIES COMPILE_DEFINITIONS "OTHER" )
endif()
now, in the sub of this I have unit tests which need to know about this compile defs, hence I have the same if/else again.
Is there an easy way for this?
Thanks,
Olaf
--
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list