1cmake_minimum_required(VERSION 2.8.1)
2project(UnitTest++)
3
4option(UTPP_USE_PLUS_SIGN "Set this to OFF is you with to use '-cpp' instead of '++' in lib/include paths" ON)
5
6# get the main sources
7file(GLOB headers_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.h)
8file(GLOB sources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/*.cpp)
9source_group("" FILES ${headers_} ${sources_})
10
11# get platform specific sources
12if (WIN32)
13    add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
14    set(platformDir_ Win32)
15else()
16    set(platformDir_ Posix)
17endif(WIN32)
18
19file(GLOB platformHeaders_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${platformDir_}/*.h)
20file(GLOB platformSources_ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} UnitTest++/${platformDir_}/*.cpp)
21source_group(${platformDir_} FILES ${platformHeaders_} ${platformSources_})
22
23# create the lib
24add_library(UnitTest++ STATIC ${headers_} ${sources_} ${platformHeaders_} ${platformSources_})
25
26if(${UTPP_USE_PLUS_SIGN})
27	set_target_properties(UnitTest++ PROPERTIES OUTPUT_NAME UnitTest++)
28endif()
29
30
31# build the test runner
32file(GLOB TEST_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tests/*.cpp tests/*.h)
33source_group( "" FILES ${TEST_SRCS})
34add_executable(TestUnitTest++ ${TEST_SRCS})
35include_directories(.)
36
37if(${UTPP_USE_PLUS_SIGN})
38	set_target_properties(TestUnitTest++ PROPERTIES OUTPUT_NAME TestUnitTest++)
39endif()
40
41target_link_libraries(TestUnitTest++ UnitTest++)
42
43# turn on testing
44enable_testing()
45add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -V)
46
47# add the test runner as a test
48add_test(NAME TestUnitTest++ COMMAND TestUnitTest++ ${CONFIG_PATH} ${CONFIG_TASKS_PATH} ${SOUND_LOG_PATH})
49add_dependencies(check TestUnitTest++)
50
51
52# add install targets
53# need a custom install path?
54# define CMAKE_INSTALL_PREFIX to change root folder
55if(${UTPP_USE_PLUS_SIGN})
56	set (UTPP_INSTALL_DESTINATION "include/UnitTest++")
57else()
58	set (UTPP_INSTALL_DESTINATION "include/UnitTestPP")
59endif()
60
61install(TARGETS UnitTest++ DESTINATION lib)
62install(FILES ${headers_} DESTINATION ${UTPP_INSTALL_DESTINATION})
63install(FILES ${platformHeaders_} DESTINATION ${UTPP_INSTALL_DESTINATION}/${platformDir_})