1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
########################################################
#
# This is a CMake configuration file.
# To use it you need CMake which can be
# downloaded from here:
# http://www.cmake.org/cmake/resources/software.html
#
#########################################################
cmake_minimum_required( VERSION 2.8 )
# Print a message and fail for people who don't
# read the build instructions and then complain
# when the build process fails for them.
if ( ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR} )
message( FATAL_ERROR "You are trying to run CMake from the <top_folder>/src/FlightCrew directory, "
"instead of just from the <top_folder> directory.\nDO NOT DO THIS.\n"
"The correct way looks like this:\n"
" cmake -G '<generator_name>' /path/to/topmost/folder/in/source/package\n"
"You will probably now need to first clean your build directory." )
endif()
#############################################################################
project( FlightCrew )
file( GLOB_RECURSE SOURCES *.h *.cpp *.xsd *.dtd )
# sort, so it won't depend on readdir() order and keep the build reproducible
list( SORT SOURCES )
# The test sources are a part of a different target, so we remove them
file( GLOB_RECURSE to_remove tests/*.h tests/*.cpp )
if( to_remove )
list( REMOVE_ITEM SOURCES ${to_remove} )
endif()
#############################################################################
# Creating source groups for VS, Xcode
include( ${CMAKE_SOURCE_DIR}/cmake_extras/FileSystemSourceGroups.cmake )
create_source_groups( SOURCES )
#############################################################################
set( PCH_NAME stdafx )
# stdafx.cpp is compiled separately as a PCH
if( NOT SKIP_PCH )
file( GLOB to_remove ${PCH_NAME}.cpp )
list( REMOVE_ITEM SOURCES ${to_remove} )
endif()
#############################################################################
# creating PCH's for MSVC and GCC on Linux
include( ${CMAKE_SOURCE_DIR}/cmake_extras/CustomPCH.cmake )
set( ALL_INCLUDES ${zipios_SOURCE_DIR} )
set( GCC_PCH_TARGET gccPCH_fc )
if( NOT SKIP_PCH )
precompiled_header( SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} )
endif()
#############################################################################
# We need to pick up the stdafx.h file (current source dir),
# and the headers for the linked-to libraries
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}
../zipios
../XercesExtensions
../utf8-cpp
)
# and pick up the stdafx.h.gch file (current binary dir) if generating PCHs
if( NOT SKIP_PCH )
list( INSERT include_directories 0 ${CMAKE_CURRENT_BINARY_DIR} )
endif()
link_directories ( ${PROJECT_BINARY_DIR}/lib )
if( BUILD_SHARED_FC )
# Windows clients also need to specify FC_BUILT_AS_DLL
# when they want a dll, but NOT FC_DLL_EXPORTING
add_definitions( -DFC_DLL_EXPORTING -DFC_BUILT_AS_DLL )
add_library( ${PROJECT_NAME} SHARED ${SOURCES} )
SET_TARGET_PROPERTIES(
${PROJECT_NAME}
PROPERTIES
SOVERSION 0
VERSION 0.9.3
)
else()
add_library( ${PROJECT_NAME} STATIC ${SOURCES} )
endif()
find_library(LIB_ZLIB z)
find_library(BOOST_DT boost_date_time)
find_library(BOOST_FS boost_filesystem)
find_library(BOOST_PO boost_program_options)
find_library(BOOST_RE boost_regex)
find_library(BOOST_S boost_system)
find_library(BOOST_T boost_thread)
find_library(LIB_XERCES xerces-c)
find_library(PTHREAD pthread)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS -Wl,--as-needed)
target_link_libraries( ${PROJECT_NAME} ${LIB_ZLIB} ${BOOST_DT} ${BOOST_FS} ${BOOST_PO} ${BOOST_RE} ${BOOST_S} ${BOOST_T} zipios ${LIB_XERCES} XercesExtensions ${PTHREAD} )
INSTALL(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib COMPONENT libraries)
INSTALL(FILES flightcrew.h exception.h DllExporting.h Result.h Misc/ErrorResultCollector.h ResultId.h ResultType.h ../XercesExtensions/NodeLocationInfo.h DESTINATION include/${PROJECT_NAME})
#############################################################################
if( NOT SKIP_PCH )
# Xcode PCH support. Has to come after the target is created.
xcode_pch( ${PCH_NAME} )
endif()
#############################################################################
# "Link time code generation" flags for MSVC
# TODO: split into special cmake file
if( MSVC )
add_definitions( /DUNICODE /D_UNICODE /W4 )
# This warning is present only at the highest warning level (/W4)
# and is routinely disabled because it complains about valid
# constructs like "while (true)"
add_definitions( /wd4127 )
# The /Zc:wchar_t- flag can't go into add_definitions
# because the RC compiler picks it up too and it provokes a name clash
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t- /MP")
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
elseif( CMAKE_COMPILER_IS_GNUCXX )
# "Print all warnings" flag for GCC
add_definitions( -Wall )
if( NOT SKIP_PCH )
# Make sure the PCH is built for GCC
add_dependencies( ${PROJECT_NAME} ${GCC_PCH_TARGET} )
endif()
endif()
#############################################################################
# We don't build the tests when fc is built as a shared
# library on msvc since the tests need access to the fc
# internal apis which are not exported when building a DLL.
# If we tried to build them, we would get linker errors.
# We also don't build the tests if the user specified it.
if( NOT ( BUILD_SHARED_FC AND MSVC ) AND NOT NO_TEST_EXE )
add_subdirectory( tests )
endif()
|