You might be able to get away with something like:
OPTION(BUILD_TESTING "Build Unit Testing" ON)
IF(BUILD_TESTING)
ENABLE_TESTING()
ADD_DEFINITIONS(-WINCLUDE_TEST_CODE)
ENDIF(BUILD_TESTING)
Then in ccmake/cmake-gui you can toggle the "ENABLE_TESTING" checkbox
on and off. There may be some ramifications of this that I am not
thinking of but _should_ work. You may want to add:
IF(NOT BUILD_TESTING)
REMOVE_DEFINITIONS(-WINCLUDE_TEST_CODE)
ENDIF(NOT BUILD_TESTING)
There is also this type of code:
IF ( CMAKE_BUILD_TYPE MATCHES Debug )
ADD_DEFINITIONS(-Wall)
ENDIF ( CMAKE_BUILD_TYPE MATCHES Debug )
Either might get you where you want. There are only 4
"Configurations" that CMake knows about (at least to my
understanding, I may be wrong)
Debug, Release, ReleaseWithDebug and ReleaseMinSize or something
along those lines. Probably the first option will get you what you want.
Also with CMake, the philosophy is to create a separate build
directory for each configuration although this is not necessary. You
can always rerun cmake and turn OFF the testing and recompile.
--
Mike Jackson Senior Research Engineer
Innovative Management & Technology Services
On Aug 18, 2008, at 11:01 AM, Steven Dwyer wrote:
I should clarify my original question,
Our unit/functional tests appear in the same files as the source
they're exercising (we use ifdefs to control if they're compiled in
or not).
I think you're suggesting that we add new targets for each existing
configuration (e.g. Debug outputs program.exe and program-test.exe)
whereas I'd rather use configurations (e.g. Debug outputs
program.exe and Test outputs program.exe)
I think this is required because of the need to ifdef in/out the
test code.
I did look through the links you suggested and will definitely
spend more time looking at them.
Steven
-----Original Message-----
From: Mike Jackson [mailto:[EMAIL PROTECTED]
Sent: August 18, 2008 10:04 AM
To: Steven Dwyer
Cc: [email protected]
Subject: Re: [CMake] Build different targets depending on build
configuration
2. If the Debug/Release configurations build an executable, the
test configuration should also build an executable and run it after
it is built.
I use the Boost unit testing framework and what I do is add "testing"
targets that build my unit tests (optionally) every time I compile.
After the compile I run "make test" and all the units tests are
executed.
3. If the Debug/Release configurations build a library, the test
configuration should build an executable and run it after it is
built.
Same idea as #2. There are some pointers in the CMake wiki about
setting all this up but just keep asking questions here as you will
find the cmake community very willing to help.
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake