]> git.donarmstrong.com Git - flightcrew.git/blob - src/FlightCrew/tests/CMakeLists.txt
Imported Upstream version 0.7.2+dfsg
[flightcrew.git] / src / FlightCrew / tests / CMakeLists.txt
1 ########################################################\r
2 #  \r
3 #  This is a CMake configuration file.\r
4 #  To use it you need CMake which can be \r
5 #  downloaded from here: \r
6 #    http://www.cmake.org/cmake/resources/software.html\r
7 #\r
8 #########################################################\r
9 \r
10 cmake_minimum_required( VERSION 2.8 ) \r
11 \r
12 project( fc_tests )\r
13      \r
14 # Normally we wouldn't include the xml files in the SOURCES just\r
15 # to get nice source groups from the create_source_groups() macro,\r
16 # but a CMake bug is forcing us to do so. It refuses to work if we \r
17 # glob for xml files separately and then run create_source_groups()\r
18 # again... putting them in the SOURCES fixes this, and they're not\r
19 # doing any realy harm. CMake is smart enough to not forward them to the compiler.\r
20 file( GLOB_RECURSE TEST_SOURCES *.cpp *.xml )\r
21 \r
22 # Creating source groups for VS, Xcode\r
23 include( ${CMAKE_SOURCE_DIR}/cmake_extras/FileSystemSourceGroups.cmake )\r
24 create_source_groups( TEST_SOURCES )\r
25 \r
26 #############################################################################\r
27 \r
28 set( PCH_NAME stdafx_tests )\r
29 \r
30 # stdafx.cpp is compiled separately as a PCH\r
31 file( GLOB to_remove ${PCH_NAME}.cpp )\r
32 list( REMOVE_ITEM TEST_SOURCES ${to_remove} )\r
33 \r
34 #############################################################################\r
35 \r
36 # We need to pick up the stdafx.h file (current source dir),\r
37 # the stdafx.h.gch file (current binary dir)\r
38 # and the headers for the linked-to libraries\r
39 \r
40 # Include_directories is ADDITIVE on folder recursion!\r
41 # That means that subdirs inherit the include_directories of their parents.\r
42 # So techincally we don't need to include Xerces etc.\r
43 include_directories( ${CMAKE_CURRENT_BINARY_DIR} \r
44                      ${CMAKE_CURRENT_SOURCE_DIR} \r
45                      ../../BoostParts \r
46                      ../../Xerces \r
47                      ../../XercesExtensions \r
48                      ../../googlemock/include\r
49                      ../../googlemock/gtest/include\r
50                    )\r
51 \r
52 link_directories ( ${PROJECT_BINARY_DIR}/lib ) \r
53 \r
54 #############################################################################\r
55 \r
56 # creating PCH's for MSVC and GCC on Linux\r
57 include( ${CMAKE_SOURCE_DIR}/cmake_extras/CustomPCH.cmake )\r
58 set( ALL_INCLUDES ${gtest_SOURCE_DIR}/include ${BoostParts_SOURCE_DIR} )\r
59 \r
60 set( GCC_PCH_TARGET gccPCH_tests )\r
61 \r
62 precompiled_header( TEST_SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} )\r
63 \r
64 #############################################################################\r
65 \r
66 add_executable( ${PROJECT_NAME} ${TEST_SOURCES} )\r
67 \r
68 target_link_libraries( ${PROJECT_NAME} FlightCrew gmock )\r
69 \r
70 #############################################################################\r
71 \r
72 # Xcode PCH support. Has to come after the target is created.              \r
73 if( APPLE )                   \r
74     set_target_properties(\r
75         ${PROJECT_NAME} \r
76         PROPERTIES\r
77         XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/${PCH_NAME}.h"\r
78         XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES"\r
79     )\r
80 endif() \r
81 \r
82 #############################################################################\r
83 \r
84 if( MSVC )\r
85     add_definitions( /DUNICODE /D_UNICODE /W4 )\r
86     \r
87     # This warning is present only at the highest warning level (/W4)\r
88     # and is routinely disabled because it complains about valid \r
89     # constructs like "while (true)"\r
90     add_definitions( /wd4127 )\r
91     \r
92     # The /Zc:wchar_t- flag can't go into add_definitions\r
93     # because the RC compiler picks it up too and it provokes a name clash\r
94     set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")\r
95     set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" ) \r
96     set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )\r
97     \r
98 elseif( CMAKE_COMPILER_IS_GNUCXX )\r
99     # Make sure the PCH is built for GCC\r
100     add_dependencies( ${PROJECT_NAME} ${GCC_PCH_TARGET} )\r
101 endif()\r
102 \r
103 # needed for correct Xerces header inclusion\r
104 add_definitions( -DXERCES_STATIC_LIBRARY )\r
105 \r
106 #############################################################################\r
107 \r
108 # The test executable expects a "test_data" dir in its working directory.\r
109 if ( NOT MSVC_IDE )\r
110     add_custom_target( copy_test_data \r
111                        COMMAND cmake -E copy_directory \r
112                        ${CMAKE_CURRENT_SOURCE_DIR}/test_data \r
113                        ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_data )\r
114 else()\r
115     # MSVC_IDE creates the test executable in a Release or Debug subdir (depending\r
116     # on the build configuration) so we copy the data there in this case.\r
117     add_custom_target( copy_test_data \r
118                        COMMAND cmake -E copy_directory \r
119                        ${CMAKE_CURRENT_SOURCE_DIR}/test_data \r
120                        ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/test_data                       \r
121                        COMMAND cmake -E copy_directory \r
122                        ${CMAKE_CURRENT_SOURCE_DIR}/test_data \r
123                        ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/test_data )\r
124 endif()\r
125 \r
126 add_dependencies( ${PROJECT_NAME} copy_test_data )\r
127 \r