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