From b67951721e6264b1b4dbc5a853b52bda8995cd8b Mon Sep 17 00:00:00 2001 From: SARL ENR 68 <david@david.david> Date: Wed, 18 Nov 2015 19:15:50 +0100 Subject: [PATCH] Merge all patches into a single patch --- CMakeLists.txt | 35 +++++++++++++---- src/BoostParts/CMakeLists.txt | 4 ++ src/FlightCrew-cli/CMakeLists.txt | 2 +- src/FlightCrew-gui/CMakeLists.txt | 2 +- src/FlightCrew-plugin/CMakeLists.txt | 2 +- src/FlightCrew/CMakeLists.txt | 34 ++++++++++++++--- src/FlightCrew/FindFlightCrew.cmake | 50 ++++++++++++++++++++++++ src/Xerces/CMakeLists.txt | 3 ++ src/XercesExtensions/CMakeLists.txt | 24 +++++++++++- src/XercesExtensions/FindXercesExtensions.cmake | 51 +++++++++++++++++++++++++ src/utf8-cpp/utf8/core.h | 2 +- src/zipios/CMakeLists.txt | 41 +++++++++++++++++--- src/zlib/CMakeLists.txt | 4 ++ 13 files changed, 230 insertions(+), 24 deletions(-) create mode 100644 src/FlightCrew/FindFlightCrew.cmake create mode 100644 src/XercesExtensions/FindXercesExtensions.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d743a93..4a21e7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ set( FLIGHTCREW_MAJOR_VERSION 0 ) set( FLIGHTCREW_MINOR_VERSION 7 ) set( FLIGHTCREW_REVISION_VERSION 2 ) set( FLIGHTCREW_FULL_VERSION ${FLIGHTCREW_MAJOR_VERSION}.${FLIGHTCREW_MINOR_VERSION}.${FLIGHTCREW_REVISION_VERSION} ) +set( FLIGHTCREW_SOVERSION ${FLIGHTCREW_FULL_VERSION} ) +set( FLIGHTCREW_LIBVERSION ${FLIGHTCREW_SOVERSION} ) # Check if platform is 64 bit if( NOT APPLE ) @@ -39,10 +41,21 @@ set( CMAKE_OSX_DEPLOYMENT_TARGET "10.9" ) # Universal builds for mac # set( CMAKE_OSX_ARCHITECTURES "i386;x86_64" ) +find_package( Boost COMPONENTS date_time filesystem program_options regex system thread system) +find_package( ZLIB ) +find_package( PkgConfig ) +pkg_check_modules( XERCES xerces-c>=3.1 ) # The parsing order is significant! -add_subdirectory( src/BoostParts ) +if( Boost_FOUND ) + set( BOOST_LIBS ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ) + set( BOOST_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ) +else() + add_subdirectory( src/BoostParts ) + set( BOOST_LIBS BoostParts ) + set( BOOST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/BoostParts ) +endif() # Set these so zipios doesn't complain. set( Boost_DATE_TIME_LIBRARY 1 ) set( Boost_FILESYSTEM_LIBRARY 1 ) @@ -50,20 +63,26 @@ set( Boost_PROGRAM_OPTIONS_LIBRARY 1 ) set( Boost_REGEX_LIBRARY 1 ) set( Boost_SYSTEM_LIBRARY 1 ) set( Boost_THREAD_LIBRARY 1 ) -set( BOOST_LIBS BoostParts ) -set( BOOST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/BoostParts ) -add_subdirectory( src/Xerces ) -set( XERCES_LIBRARIES Xerces ) -set( XERCES_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/Xerces ) +if( NOT XERCES_FOUND ) + add_subdirectory( src/Xerces ) + set( XERCES_LIBRARIES Xerces ) + set( XERCES_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/Xerces ) +endif() add_subdirectory( src/XercesExtensions ) set( XERCESEXTENSIONS_LIBRARIES XercesExtensions ) set( XERCESEXTENSIONS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/XercesExtensions ) -add_subdirectory( src/zlib ) +if( NOT ZLIB_FOUND ) + add_subdirectory( src/zlib ) +endif() + add_subdirectory( src/zipios ) -add_subdirectory( src/googlemock ) + +if( NOT NO_TEST_EXE ) + add_subdirectory( src/googlemock ) +endif() add_subdirectory( src/FlightCrew ) set( FLIGHTCREW_LIBRARIES FlightCrew ) diff --git a/src/BoostParts/CMakeLists.txt b/src/BoostParts/CMakeLists.txt index 520f120..9490b21 100644 --- a/src/BoostParts/CMakeLists.txt +++ b/src/BoostParts/CMakeLists.txt @@ -111,3 +111,7 @@ if( MSVC ) set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" ) set_target_properties( ${PROJECT_NAME} PROPERTIES STATIC_LIBRARY_FLAGS "/LTCG" ) endif() + +if( UNIX AND BUILD_SHARED_FC ) + add_definitions(-fPIC) +endif() diff --git a/src/FlightCrew-cli/CMakeLists.txt b/src/FlightCrew-cli/CMakeLists.txt index fbdd67b..fabef5b 100644 --- a/src/FlightCrew-cli/CMakeLists.txt +++ b/src/FlightCrew-cli/CMakeLists.txt @@ -30,7 +30,7 @@ create_source_groups( SOURCES ) # We need to pick up the stdafx.h file # and the headers for the linked-to libraries include_directories( ${CMAKE_CURRENT_SOURCE_DIR} - ${BoostParts_SOURCE_DIR} + ${BOOST_INCLUDE_DIRS} ${FlightCrew_SOURCE_DIR} ${XercesExtensions_SOURCE_DIR} ) diff --git a/src/FlightCrew-gui/CMakeLists.txt b/src/FlightCrew-gui/CMakeLists.txt index 97b9d79..cb0811a 100644 --- a/src/FlightCrew-gui/CMakeLists.txt +++ b/src/FlightCrew-gui/CMakeLists.txt @@ -82,7 +82,7 @@ create_source_groups( RAW_SOURCES ) include_directories( BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${BoostParts_SOURCE_DIR} + ${BOOST_INCLUDE_DIRS} ${FlightCrew_SOURCE_DIR} ${XercesExtensions_SOURCE_DIR} ) diff --git a/src/FlightCrew-plugin/CMakeLists.txt b/src/FlightCrew-plugin/CMakeLists.txt index 379326e..c46454f 100644 --- a/src/FlightCrew-plugin/CMakeLists.txt +++ b/src/FlightCrew-plugin/CMakeLists.txt @@ -30,7 +30,7 @@ create_source_groups( SOURCES ) # We need to pick up the stdafx.h file # and the headers for the linked-to libraries include_directories( ${CMAKE_CURRENT_SOURCE_DIR} - ${BoostParts_SOURCE_DIR} + ${BOOST_INCLUDE_DIRS} ${FlightCrew_SOURCE_DIR} ${XercesExtensions_SOURCE_DIR} ) diff --git a/src/FlightCrew/CMakeLists.txt b/src/FlightCrew/CMakeLists.txt index da3a796..48fd662 100644 --- a/src/FlightCrew/CMakeLists.txt +++ b/src/FlightCrew/CMakeLists.txt @@ -50,8 +50,8 @@ list( REMOVE_ITEM SOURCES ${to_remove} ) # creating PCH's for MSVC and GCC on Linux include( ${CMAKE_SOURCE_DIR}/cmake_extras/CustomPCH.cmake ) -set( ALL_INCLUDES ${BoostParts_SOURCE_DIR} - ${Xerces_SOURCE_DIR} +set( ALL_INCLUDES ${BOOST_INCLUDE_DIRS} + ${XERCES_INCLUDE_DIRS} ${zipios_SOURCE_DIR} ) set( GCC_PCH_TARGET gccPCH_fc ) @@ -65,8 +65,8 @@ precompiled_header( SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} ) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ../zipios - ../BoostParts - ../Xerces + ${BOOST_INCLUDE_DIRS} + ${XERCES_INCLUDE_DIRS} ../XercesExtensions ../utf8-cpp ) @@ -78,11 +78,16 @@ if( BUILD_SHARED_FC ) # 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 + VERSION "${FLIGHTCREW_LIBVERSION}" + SOVERSION "${FLIGHTCREW_SOVERSION}" + OUTPUT_NAME "${PROJECT_NAME}" + ) else() add_library( ${PROJECT_NAME} ${SOURCES} ) endif() -target_link_libraries( ${PROJECT_NAME} zipios BoostParts XercesExtensions ) +target_link_libraries( ${PROJECT_NAME} zipios ${BOOST_LIBS} XercesExtensions ) ############################################################################# @@ -116,7 +121,9 @@ elseif( CMAKE_COMPILER_IS_GNUCXX ) endif() # needed for correct Xerces header inclusion -add_definitions( -DXERCES_STATIC_LIBRARY ) +if( NOT XERCES_FOUND ) + add_definitions( -DXERCES_STATIC_LIBRARY ) +endif() ############################################################################# @@ -128,3 +135,18 @@ add_definitions( -DXERCES_STATIC_LIBRARY ) if( NOT ( BUILD_SHARED_FC AND MSVC ) AND NOT NO_TEST_EXE ) add_subdirectory( tests ) endif() + +if( UNIX AND NOT APPLE ) + install( TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} + ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} + ) + file( GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.h" ) + install( FILES ${files} DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME} ) + file( GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/Misc/*.h" ) + install( FILES ${files} DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/Misc ) + file( GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/Validators/*.h" ) + install( FILES ${files} DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/Validators ) + install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/../XercesExtensions/NodeLocationInfo.h DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME} ) + install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/FindFlightCrew.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/cmake/${PROJECT_NAME} ) +endif() diff --git a/src/FlightCrew/FindFlightCrew.cmake b/src/FlightCrew/FindFlightCrew.cmake new file mode 100644 index 0000000..fe7d08a --- /dev/null +++ b/src/FlightCrew/FindFlightCrew.cmake @@ -0,0 +1,50 @@ +# Try to find the FlightCrew lib +# Once done this will define: +# +# FLIGHTCREW_FOUND - system has FlightCrew +# FLIGHTCREW_INCLUDE_DIRS - the FlightCrew include directory +# FLIGHTCREW_LIBRARIES - The libraries needed to use FlightCrew +# +# Copyright (c) 2011, Dan Horák <dan[at]danny.cz> +# Copyright (c) 2012, Hans de Goede <hdegoede@redhat.com> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if (FLIGHTCREW_INCLUDE_DIRS) + # Already in cache, be silent + set(FLIGHTCREW_FIND_QUIETLY TRUE) +endif (FLIGHTCREW_INCLUDE_DIRS) + +#FIND_PATH(FLIGHTCREW_INCLUDE_DIRS flightcrew.h) + +if( NOT FLIGHTCREW_INCLUDE_DIRS ) + find_path(FLIGHTCREW_INCLUDE_DIRS flightcrew.h PATH_SUFFIXES FlightCrew) + #now flightcrew.h was inside a FlightCrew subdirectory so we need to + #add that to the include dir + set(FLIGHTCREW_INCLUDE_DIRS ${FLIGHTCREW_INCLUDE_DIRS}/FlightCrew CACHE PATH "FlightCrew include directory") +endif( NOT FLIGHTCREW_INCLUDE_DIRS ) + + +FIND_LIBRARY(FLIGHTCREW_LIBRARIES NAMES FlightCrew) + +if (FLIGHTCREW_INCLUDE_DIRS AND FLIGHTCREW_LIBRARIES) + set(FLIGHTCREW_FOUND TRUE) +endif (FLIGHTCREW_INCLUDE_DIRS AND FLIGHTCREW_LIBRARIES) + + +if (FLIGHTCREW_FOUND) + if (NOT FLIGHTCREW_FIND_QUIETLY) + message(STATUS "Found FlightCrew: ${FLIGHTCREW_LIBRARIES}") + endif (NOT FLIGHTCREW_FIND_QUIETLY) +else (FLIGHTCREW_FOUND) + if (FLIGHTCREW_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find FlightCrew") + else (FLIGHTCREW_FIND_REQUIRED) + message(STATUS "Could NOT find FlightCrew") + endif (FLIGHTCREW_FIND_REQUIRED) +endif (FLIGHTCREW_FOUND) + +MARK_AS_ADVANCED(FLIGHTCREW_INCLUDE_DIRS FLIGHTCREW_LIBRARIES) + diff --git a/src/Xerces/CMakeLists.txt b/src/Xerces/CMakeLists.txt index e7c67ed..8da6f64 100644 --- a/src/Xerces/CMakeLists.txt +++ b/src/Xerces/CMakeLists.txt @@ -174,4 +174,7 @@ else() # We need to link to pthreads on unix target_link_libraries( ${PROJECT_NAME} pthread ) + if( BUILD_SHARED_FC ) + add_definitions(-fPIC) + endif() endif() diff --git a/src/XercesExtensions/CMakeLists.txt b/src/XercesExtensions/CMakeLists.txt index 52c9fb3..c165711 100644 --- a/src/XercesExtensions/CMakeLists.txt +++ b/src/XercesExtensions/CMakeLists.txt @@ -21,7 +21,19 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} link_directories ( ${PROJECT_BINARY_DIR}/lib ) -add_library( ${PROJECT_NAME} ${SOURCES} ) +if( BUILD_SHARED_XE ) + add_library( ${PROJECT_NAME} SHARED ${SOURCES} ) + set_target_properties( ${PROJECT_NAME} PROPERTIES + VERSION "${FLIGHTCREW_LIBVERSION}" + SOVERSION "${FLIGHTCREW_SOVERSION}" + OUTPUT_NAME "${PROJECT_NAME}" + ) +else() + add_library( ${PROJECT_NAME} ${SOURCES} ) + if( UNIX AND BUILD_SHARED_FC ) + add_definitions(-fPIC) + endif() +endif() target_link_libraries( ${PROJECT_NAME} ${XERCES_LIBRARIES} ) @@ -53,3 +65,13 @@ if( FORCE_BUNDLED_COPIES OR NOT XERCES_FOUND) add_definitions( -DXERCES_STATIC_LIBRARY ) endif() +if( BUILD_SHARED_XE AND UNIX AND NOT APPLE ) + install( TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} + ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} + ) + file( GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.h" ) + install( FILES ${files} DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME} ) + install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/FindXercesExtensions.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/cmake/${PROJECT_NAME} ) +endif() + diff --git a/src/XercesExtensions/FindXercesExtensions.cmake b/src/XercesExtensions/FindXercesExtensions.cmake new file mode 100644 index 0000000..0d32275 --- /dev/null +++ b/src/XercesExtensions/FindXercesExtensions.cmake @@ -0,0 +1,51 @@ +# Try to find the XercesExtensions lib +# Once done this will define: +# +# XERCESEXTENSIONS_FOUND - system has XercesExtensions +# XERCESEXTENSIONS_INCLUDE_DIRS - the XercesExtensions include directory +# XERCESEXTENSIONS_LIBRARIES - The libraries needed to use XercesExtensions +# +# Copyright (c) 2011, Dan Horák <dan[at]danny.cz> +# Copyright (c) 2012, Hans de Goede <hdegoede@redhat.com> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if (XERCESEXTENSIONS_INCLUDE_DIRS) + # Already in cache, be silent + set(XERCESEXTENSIONS_FIND_QUIETLY TRUE) +endif (XERCESEXTENSIONS_INCLUDE_DIRS) + +#FIND_PATH(XERCESEXTENSIONS_INCLUDE_DIRS XercesInit.h) + +if( NOT XERCESEXTENSIONS_INCLUDE_DIRS ) + find_path(XERCESEXTENSIONS_INCLUDE_DIRS XercesInit.h PATH_SUFFIXES XercesExtensions) + #now XercesInit.h was inside a XercesExtensions subdirectory so we need to + #add that to the include dir + set(XERCESEXTENSIONS_INCLUDE_DIRS ${XERCESEXTENSIONS_INCLUDE_DIRS}/XercesExtensions CACHE PATH "XercesExtensions include directory") +endif( NOT XERCESEXTENSIONS_INCLUDE_DIRS ) + + +FIND_LIBRARY(XERCESEXTENSIONS_LIBRARIES NAMES XercesExtensions) + +if (XERCESEXTENSIONS_INCLUDE_DIRS AND XERCESEXTENSIONS_LIBRARIES) + set(XERCESEXTENSIONS_FOUND TRUE) +endif (XERCESEXTENSIONS_INCLUDE_DIRS AND XERCESEXTENSIONS_LIBRARIES) + + +if (XERCESEXTENSIONS_FOUND) + if (NOT XERCESEXTENSIONS_FIND_QUIETLY) + message(STATUS "Found XercesExtensions: ${XERCESEXTENSIONS_LIBRARIES}") + endif (NOT XERCESEXTENSIONS_FIND_QUIETLY) +else (XERCESEXTENSIONS_FOUND) + if (XERCESEXTENSIONS_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find XercesExtensions") + else (XERCESEXTENSIONS_FIND_REQUIRED) + message(STATUS "Could NOT find XercesExtensions") + endif (XERCESEXTENSIONS_FIND_REQUIRED) +endif (XERCESEXTENSIONS_FOUND) + +MARK_AS_ADVANCED(XERCESEXTENSIONS_INCLUDE_DIRS XERCESEXTENSIONS_LIBRARIES) + + diff --git a/src/utf8-cpp/utf8/core.h b/src/utf8-cpp/utf8/core.h index 294aad0..1fe84cd 100755 --- a/src/utf8-cpp/utf8/core.h +++ b/src/utf8-cpp/utf8/core.h @@ -29,7 +29,7 @@ DEALINGS IN THE SOFTWARE. #define UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731 #include <iterator> -#include "../../BoostParts/boost/cstdint.hpp" +#include <boost/cstdint.hpp> namespace utf8 { diff --git a/src/zipios/CMakeLists.txt b/src/zipios/CMakeLists.txt index 88fdb7d..ab4ea99 100644 --- a/src/zipios/CMakeLists.txt +++ b/src/zipios/CMakeLists.txt @@ -16,16 +16,38 @@ file( GLOB_RECURSE SOURCES *.cpp *.h ) # We need to pick up the stdafx.h file # and the headers for the linked-to libraries include_directories( ${CMAKE_CURRENT_SOURCE_DIR} - ${BoostParts_SOURCE_DIR} - ${zlib_SOURCE_DIR} - ${zlib_BINARY_DIR} + ${BOOST_INCLUDE_DIRS} ) +if( ZLIB_FOUND ) + include_directories( ${ZLIB_INCLUDE_DIRS} ) +else() + include_directories( ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR} ) +endif() + link_directories ( ${PROJECT_BINARY_DIR}/lib ) -add_library( ${PROJECT_NAME} ${SOURCES} ) +if( BUILD_SHARED_ZI ) + add_library( ${PROJECT_NAME} SHARED ${SOURCES} ) + set_target_properties( ${PROJECT_NAME} PROPERTIES + VERSION "${FLIGHTCREW_LIBVERSION}" + SOVERSION "${FLIGHTCREW_SOVERSION}" + OUTPUT_NAME "${PROJECT_NAME}" + ) +else() + add_library( ${PROJECT_NAME} ${SOURCES} ) + if( UNIX AND BUILD_SHARED_FC ) + add_definitions(-fPIC) + endif() +endif() + +target_link_libraries( ${PROJECT_NAME} ${BOOST_LIBS} ) +if( ZLIB_FOUND ) + target_link_libraries( ${PROJECT_NAME} ${ZLIB_LIBRARIES} ) +else() + target_link_libraries( ${PROJECT_NAME} zlib ) +endif() -target_link_libraries( ${PROJECT_NAME} zlib BoostParts ) ############################################################################# @@ -47,3 +69,12 @@ elseif( CMAKE_COMPILER_IS_GNUCXX ) add_definitions( -Wall ) endif() +if( BUILD_SHARED_ZI AND UNIX AND NOT APPLE ) + install( TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} + ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX} + ) + file( GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/zipios++/*.h" ) + install( FILES ${files} DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}/zipios++ ) +endif() + diff --git a/src/zlib/CMakeLists.txt b/src/zlib/CMakeLists.txt index e59f844..d241848 100644 --- a/src/zlib/CMakeLists.txt +++ b/src/zlib/CMakeLists.txt @@ -133,5 +133,9 @@ if( MSVC ) set_target_properties( ${PROJECT_NAME} PROPERTIES STATIC_LIBRARY_FLAGS "/LTCG" ) endif() +if( UNIX AND BUILD_SHARED_FC ) + add_definitions(-fPIC) +endif() +