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
12 # Print a message and fail for people who don't
\r
13 # read the build instructions and then complain
\r
14 # when the build process fails for them.
\r
15 if ( ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR} )
\r
16 message( FATAL_ERROR "You are trying to run CMake from the <top_folder>/src/FlightCrew directory, "
\r
17 "instead of just from the <top_folder> directory.\nDO NOT DO THIS.\n"
\r
18 "The correct way looks like this:\n"
\r
19 " cmake -G '<generator_name>' /path/to/topmost/folder/in/source/package\n"
\r
20 "You will probably now need to first clean your build directory." )
\r
23 #############################################################################
\r
25 project( FlightCrew )
\r
27 file( GLOB_RECURSE SOURCES *.h *.cpp *.xsd *.dtd )
\r
29 # The test sources are a part of a different target, so we remove them
\r
30 file( GLOB_RECURSE to_remove tests/*.h tests/*.cpp )
\r
32 list( REMOVE_ITEM SOURCES ${to_remove} )
\r
35 #############################################################################
\r
37 # Creating source groups for VS, Xcode
\r
38 include( ${CMAKE_SOURCE_DIR}/cmake_extras/FileSystemSourceGroups.cmake )
\r
39 create_source_groups( SOURCES )
\r
41 #############################################################################
\r
43 set( PCH_NAME stdafx )
\r
45 # stdafx.cpp is compiled separately as a PCH
\r
46 file( GLOB to_remove ${PCH_NAME}.cpp )
\r
47 list( REMOVE_ITEM SOURCES ${to_remove} )
\r
49 #############################################################################
\r
51 # creating PCH's for MSVC and GCC on Linux
\r
52 include( ${CMAKE_SOURCE_DIR}/cmake_extras/CustomPCH.cmake )
\r
53 set( ALL_INCLUDES ${BoostParts_SOURCE_DIR}
\r
54 ${Xerces_SOURCE_DIR}
\r
55 ${zipios_SOURCE_DIR} )
\r
56 set( GCC_PCH_TARGET gccPCH_fc )
\r
58 precompiled_header( SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} )
\r
60 #############################################################################
\r
62 # We need to pick up the stdafx.h file (current source dir),
\r
63 # the stdafx.h.gch file (current binary dir)
\r
64 # and the headers for the linked-to libraries
\r
65 include_directories( ${CMAKE_CURRENT_BINARY_DIR}
\r
66 ${CMAKE_CURRENT_SOURCE_DIR}
\r
74 link_directories ( ${PROJECT_BINARY_DIR}/lib )
\r
76 if( BUILD_SHARED_FC )
\r
77 # Windows clients also need to specify FC_BUILT_AS_DLL
\r
78 # when they want a dll, but NOT FC_DLL_EXPORTING
\r
79 add_definitions( -DFC_DLL_EXPORTING -DFC_BUILT_AS_DLL )
\r
80 add_library( ${PROJECT_NAME} SHARED ${SOURCES} )
\r
82 add_library( ${PROJECT_NAME} ${SOURCES} )
\r
85 target_link_libraries( ${PROJECT_NAME} zipios BoostParts XercesExtensions )
\r
87 #############################################################################
\r
89 # Xcode PCH support. Has to come after the target is created.
\r
90 xcode_pch( ${PCH_NAME} )
\r
92 #############################################################################
\r
94 # "Link time code generation" flags for MSVC
\r
95 # TODO: split into special cmake file
\r
97 add_definitions( /DUNICODE /D_UNICODE /W4 )
\r
99 # This warning is present only at the highest warning level (/W4)
\r
100 # and is routinely disabled because it complains about valid
\r
101 # constructs like "while (true)"
\r
102 add_definitions( /wd4127 )
\r
104 # The /Zc:wchar_t- flag can't go into add_definitions
\r
105 # because the RC compiler picks it up too and it provokes a name clash
\r
106 set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-")
\r
107 set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" )
\r
108 set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
\r
110 elseif( CMAKE_COMPILER_IS_GNUCXX )
\r
111 # "Print all warnings" flag for GCC
\r
112 add_definitions( -Wall )
\r
114 # Make sure the PCH is built for GCC
\r
115 add_dependencies( ${PROJECT_NAME} ${GCC_PCH_TARGET} )
\r
118 # needed for correct Xerces header inclusion
\r
119 add_definitions( -DXERCES_STATIC_LIBRARY )
\r
121 #############################################################################
\r
123 # We don't build the tests when fc is built as a shared
\r
124 # library on msvc since the tests need access to the fc
\r
125 # internal apis which are not exported when building a DLL.
\r
126 # If we tried to build them, we would get linker errors.
\r
127 # We also don't build the tests if the user specified it.
\r
128 if( NOT ( BUILD_SHARED_FC AND MSVC ) AND NOT NO_TEST_EXE )
\r
129 add_subdirectory( tests )
\r