1 ########################################################
\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
8 #########################################################
\r
10 cmake_minimum_required( VERSION 2.8 )
\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
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
26 #############################################################################
\r
28 set( PCH_NAME stdafx_tests )
\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
34 #############################################################################
\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
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
47 ../../XercesExtensions
\r
48 ../../googlemock/include
\r
49 ../../googlemock/gtest/include
\r
52 link_directories ( ${PROJECT_BINARY_DIR}/lib )
\r
54 #############################################################################
\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
60 set( GCC_PCH_TARGET gccPCH_tests )
\r
62 precompiled_header( TEST_SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} )
\r
64 #############################################################################
\r
66 add_executable( ${PROJECT_NAME} ${TEST_SOURCES} )
\r
68 target_link_libraries( ${PROJECT_NAME} FlightCrew gmock )
\r
70 #############################################################################
\r
72 # Xcode PCH support. Has to come after the target is created.
\r
74 set_target_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
82 #############################################################################
\r
85 add_definitions( /DUNICODE /D_UNICODE /W4 )
\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
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
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
103 # needed for correct Xerces header inclusion
\r
104 add_definitions( -DXERCES_STATIC_LIBRARY )
\r
106 #############################################################################
\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
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
126 add_dependencies( ${PROJECT_NAME} copy_test_data )
\r