[CMake] cmake and buildvariants

Eric Noulard eric.noulard at gmail.com
Mon Jan 10 17:39:53 EST 2011


2011/1/10 John Beuving <johnbeuving at gmail.com>:
>
> I have the following software setup where I need to have build variants
> providing different builds for the same (sub)project
>
> -    worker ( calls the Qt Processevents function if Qt is enabled for this
> project (#define  USE_WORKER_QT)
> -    gui app (uses Qt)
> -    console app (normal application used for data export)
>
>
> So the gui application uses Qt and needs to use the worker static library
> with the define USE_WORKER_QT set
> and the console application needs a variant build of the worker library
> where USE_WORKER_QT is not set.
>
> How can I achieve this. Is this even possible with cmake ??

You may build your worker lib twice:

# first build USE_WORKER_QT is not set
add_library(worker-noqt STATIC ${WORKER_SRC})

# second build USE_WORKER_QT set
add_library(worker-qt STATIC ${WORKER_SRC})
set_target_properties(worker-qt PROPERTIES COMPILE_FLAGS "-DUSE_WORKER_QT")

#link the apps with the appropriate build of the worker lib

add_executable(gui-app ${GUI_SRC})
target_link_libraries(gui-app worker-qt)

add_executable(console-app ${CONSOLE_SRC})
target_link_libraries(console-app worker-noqt)

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list