[CMake] Top-Level Project with libs and unit test

Olaf Peter ope-devel at gmx.de
Fri Mar 26 15:34:27 EDT 2010


Hi,

I've a top level project which is using Qt. Therefore I've a lot of
defines and compiler switches on.
Further more, there is an of Qt independent library with unit tests.

$ cat project/CMakeLists.txt
...
add_definitions(-DQT_NO_KEYWORDS)
add_definitions(-DQT_NO_CAST_FROM_ASCII)
add_definitions(-DQT_NO_CAST_TO_ASCII)
...

$ cat project/molp/CMakeLists.txt
project(molp)
set(molp_SOURCES grammar.cpp)
add_library(molp STATIC ${molp_SOURCES})
add_subdirectory(test)

$ cat project/molp/test/CMakeLists.txt
project(molp_unit_test)
set(CMAKE_CXX_FLAGS "-g") # wont' work
set(molp_ut_SOURCES test.cpp )

add_executable( molp_ut ${molp_ut_SOURCES} )
target_link_libraries( molp_ut molp )
add_test(
  NAME    molp
  COMMAND molp_ut --run_test=all )

How to set the compiler defines/switches for the  sub-projects?

Thanks,
Olaf



More information about the CMake mailing list