[CMake] Correct way to add definitions
Mike Jackson
imikejackson at gmail.com
Fri Nov 16 17:19:09 EST 2007
I am trying to create a cmake build system for a 3rd party library.
The trouble I am having is that I need a definition for the dynamic
library ONLY, but when I build the ensuing test executables I need to
have a _different_ definition defined.
At first I did the usual:
IF(BUILD_SHARED_LIBS)
IF (WIN32)
ADD_DEFINITION(-D_BUILD_DLL_)
ENDIF(WIN32)
ENDIF (BUILD_SHARED_LIBS)
Then in I have ADD_SUBDIRECTORY(test)
and in the test/CMakeLists.txt file I have
IF(BUILD_SHARED_LIBS)
IF (WIN32)
ADD_DEFINITION(-D_USE_DLL_)
ENDIF(WIN32)
ENDIF (BUILD_SHARED_LIBS)
but when I create my VS2003.net project from CMake (2.4.6) I get BOTH
definitions in the testing targets. I also tried the following for
each target:
IF(BUILD_SHARED_LIBS)
IF (WIN32)
SET_TARGET_PROPERTIES( dangle PROPERTIES DEFINE_SYMBOL _USE_DLL_)
ENDIF(WIN32)
ENDIF (BUILD_SHARED_LIBS)
But that does not seem to work either..
A little help please...
Thanks
--
Mike Jackson
imikejackson _at_ gee-mail dot com
More information about the CMake
mailing list