diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-10-24 18:46:20 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-10-24 18:46:20 (GMT) |
commit | bb6d4295acf8050a510e30db5114ed9cf3ab6c61 (patch) | |
tree | 13a30682968644fa70971f9260c9aa703b19adb2 | |
parent | bdeaac64ec3b5c260733f84e25c65502b8f5ad01 (diff) | |
download | uscxml-bb6d4295acf8050a510e30db5114ed9cf3ab6c61.zip uscxml-bb6d4295acf8050a510e30db5114ed9cf3ab6c61.tar.gz uscxml-bb6d4295acf8050a510e30db5114ed9cf3ab6c61.tar.bz2 |
Versioning support for prebuilt dependencies
-rw-r--r-- | CMakeLists.txt | 114 |
1 files changed, 89 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b21dd0f..db2a840 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,12 +63,30 @@ if (CMAKE_CROSSCOMPILING) add_definitions(-DTARGET_IPHONE_SIMULATOR) endif() endif() + # # Setting the CMAKE_FIND_ROOT_PATH to a list of directories will cause all CMake modules # to look in these directories in addition to the system search paths: # http://www.vtk.org/Wiki/CMake_Cross_Compiling#Searching_and_finding_external_software # +SET(USCXML_PLATFORM_ID) +if (CMAKE_CROSSCOMPILING) + if (IOS) + SET(USCXML_PLATFORM_ID "ios") + elseif (ANDROID) + SET(USCXML_PLATFORM_ID "android") + else() + SET(USCXML_PLATFORM_ID "${CMAKE_SYSTEM_NAME_LC}-${CMAKE_SYSTEM_PROCESSOR}_64") + endif() +else() + if (WIN32 AND 64BIT_HOST) + SET(USCXML_PLATFORM_ID "${CMAKE_SYSTEM_NAME_LC}-${CMAKE_SYSTEM_PROCESSOR}_64") + else() + SET(USCXML_PLATFORM_ID "${CMAKE_SYSTEM_NAME_LC}-${CMAKE_SYSTEM_PROCESSOR}") + endif() +endif() + SET(USCXML_PREBUILT_LIBRARY_PATH) SET(USCXML_PREBUILT_HEADER_PATH "${PROJECT_SOURCE_DIR}/contrib/prebuilt") # search roots for libraries @@ -90,11 +108,7 @@ else () # SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM "BOTH") # SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE "BOTH") # SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "BOTH") - if (WIN32 AND 64BIT_HOST) - SET(USCXML_PREBUILT_LIBRARY_PATH "${PROJECT_SOURCE_DIR}/contrib/prebuilt/${CMAKE_SYSTEM_NAME_LC}-${CMAKE_SYSTEM_PROCESSOR}_64/${CMAKE_CXX_COMPILER_ID_LC}") - else() - SET(USCXML_PREBUILT_LIBRARY_PATH "${PROJECT_SOURCE_DIR}/contrib/prebuilt/${CMAKE_SYSTEM_NAME_LC}-${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_CXX_COMPILER_ID_LC}") - endif() + SET(USCXML_PREBUILT_LIBRARY_PATH "${PROJECT_SOURCE_DIR}/contrib/prebuilt/${USCXML_PLATFORM_ID}/${CMAKE_CXX_COMPILER_ID_LC}") endif() SET(USCXML_LIBRARY_HOST_URL_PREFIX "http://uscxml.tk.informatik.tu-darmstadt.de/prebuilt" CACHE STRING "The root path of an URL where to look for prebuilt libraries.") @@ -107,11 +121,28 @@ if (CMAKE_CROSSCOMPILING) else() endif() else() - if (WIN32 AND 64BIT_HOST) - SET(USCXML_LIBRARY_ARCHIVE_NAME uscxml-prebuilt-${CMAKE_SYSTEM_NAME_LC}-${CMAKE_SYSTEM_PROCESSOR}_64.tgz) - else() - SET(USCXML_LIBRARY_ARCHIVE_NAME uscxml-prebuilt-${CMAKE_SYSTEM_NAME_LC}-${CMAKE_SYSTEM_PROCESSOR}.tgz) - endif() + SET(USCXML_LIBRARY_ARCHIVE_NAME uscxml-prebuilt-${USCXML_PLATFORM_ID}.tgz) +endif() + + +if (EXISTS "${PROJECT_SOURCE_DIR}/contrib/prebuilt/include/VERSION.txt") + file (STRINGS "${PROJECT_SOURCE_DIR}/contrib/prebuilt/include/VERSION.txt" PREBUILT_INCUDES_VERSION) +endif() +if (NOT "${USCXML_VERSION}" VERSION_EQUAL "${PREBUILT_INCUDES_VERSION}") + message(STATUS "Prebuilt headers unversioned, too old or non-existant - downloading (again)") + execute_process( + COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_SOURCE_DIR}/contrib/prebuilt/include + ) +endif() + +if (EXISTS "${PROJECT_SOURCE_DIR}/contrib/prebuilt/${USCXML_PLATFORM_ID}/VERSION.txt") + file (STRINGS "${PROJECT_SOURCE_DIR}/contrib/prebuilt/${USCXML_PLATFORM_ID}/VERSION.txt" PREBUILT_LIBRARIES_VERSION) +endif() +if (NOT "${USCXML_VERSION}" VERSION_EQUAL "${PREBUILT_LIBRARIES_VERSION}") + message(STATUS "Prebuilt libraries unversioned, too old or non-existant - downloading (again)") + execute_process( + COMMAND ${CMAKE_COMMAND} -E remove_directory ${PROJECT_SOURCE_DIR}/contrib/prebuilt/${USCXML_PLATFORM_ID} + ) endif() if (NOT EXISTS ${PROJECT_SOURCE_DIR}/contrib/prebuilt/include) @@ -130,6 +161,7 @@ if (NOT EXISTS ${PROJECT_SOURCE_DIR}/contrib/prebuilt/include) COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_SOURCE_DIR}/contrib/prebuilt/include.tgz WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/contrib/prebuilt/ ) + file(WRITE ${PROJECT_SOURCE_DIR}/contrib/prebuilt/include/VERSION.txt "${USCXML_VERSION}") else() message("Downloading header files failed with ${STATUS_STRING}") endif() @@ -151,22 +183,25 @@ if (NOT EXISTS ${USCXML_PREBUILT_LIBRARY_PATH}) COMMAND ${CMAKE_COMMAND} -E remove ${PROJECT_SOURCE_DIR}/contrib/prebuilt/${USCXML_LIBRARY_ARCHIVE_NAME} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/contrib/prebuilt/ ) + file(WRITE ${PROJECT_SOURCE_DIR}/contrib/prebuilt/${USCXML_PLATFORM_ID}/VERSION.txt "${USCXML_VERSION}") else() message("Downloading prebuilt libraries failed with ${STATUS_STRING} - maybe this platform is not supported?") endif() - endif() if (CMAKE_CROSSCOMPILING) OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF) + OPTION(ENABLE_COTIRE "Enable compile time reduction techniques" OFF) else() OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) + OPTION(ENABLE_COTIRE "Enable compile time reduction techniques" ON) endif() if (NOT BUILD_SHARED_LIBS) add_definitions("-DUSCXML_STATIC") endif() + # # BUILD_PREFER_PREBUILT_LIBS: # Do we want to search system paths or contrib/prebuilt first? @@ -396,13 +431,8 @@ if (DIST_PREPARE) set(OUTPUT_DIR ${PROJECT_SOURCE_DIR}/package/cross-compiled/${CMAKE_CROSSCOMPILING_TARGET_LC}-${CMAKE_SYSTEM_VERSION}/${CMAKE_SYSTEM_PROCESSOR}) else() - if (WIN32 AND 64BIT_HOST) - set(OUTPUT_DIR - ${PROJECT_SOURCE_DIR}/package/${CMAKE_SYSTEM_NAME_LC}-${CMAKE_SYSTEM_PROCESSOR}_64/${CMAKE_CXX_COMPILER_ID_LC}) - else() - set(OUTPUT_DIR - ${PROJECT_SOURCE_DIR}/package/${CMAKE_SYSTEM_NAME_LC}-${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_CXX_COMPILER_ID_LC}) - endif() + set(OUTPUT_DIR + ${PROJECT_SOURCE_DIR}/package/${USCXML_PLATFORM_ID}/${CMAKE_CXX_COMPILER_ID_LC}) endif() else() set(OUTPUT_DIR ${PROJECT_BINARY_DIR}) @@ -446,6 +476,10 @@ if (NOT WIN32) # message("CMAKE_SYSTEM_PROGRAM_PATH: ${CMAKE_SYSTEM_PROGRAM_PATH}") # message("CMAKE_FIND_ROOT_PATH: ${CMAKE_FIND_ROOT_PATH}") + if (APPLE) + set(PC_LIBXML_INCLUDEDIR "/usr/include/libxml2/") + endif() + find_package(LibXml2 REQUIRED) include_directories(${LIBXML2_INCLUDE_DIR}) list (APPEND USCXML_CORE_LIBS ${LIBXML2_LIBRARIES}) @@ -768,9 +802,7 @@ endforeach() # add compile time reducer # see https://github.com/sakra/cotire -if (NOT CMAKE_CROSSCOMPILING) - include(cotire) -endif() +include(cotire) # build library if (BUILD_AS_PLUGINS) @@ -786,7 +818,9 @@ endif() if (NOT CMAKE_CROSSCOMPILING) set_target_properties(uscxml PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "src/uscxml/pch.h") set_target_properties(uscxml PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) - cotire(uscxml) + if (ENABLE_COTIRE) + cotire(uscxml) + endif() endif() if (NOT CMAKE_CROSSCOMPILING) @@ -855,6 +889,28 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DI configure_file(${CMAKE_CURRENT_SOURCE_DIR}/contrib/ctest/CTestCustom.ctest.in ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.ctest @ONCE) ############################################################ +# Include What You Use support +# https://code.google.com/p/chromium/wiki/IncludeWhatYouUse +############################################################ +# find_program(IWYU_BIN "iwyu" PATHS ENV PATH) +# if (IWYU_BIN) +# set(IWYU_ARGS "") +# get_property(IWYU_INCLUDES DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) +# list(REMOVE_DUPLICATES IWYU_INCLUDES) +# foreach(DIR ${IWYU_INCLUDES}) +# set(IWYU_ARGS "${IWYU_ARGS} -I${DIR}") +# endforeach() +# +# message(FATAL_ERROR ${IWYU_ARGS}) +# +# add_custom_target(iwyu ${IWYU_BIN} +# ${IWYU_ARGS} ${PROJECT_SOURCE_DIR}/src/uscxml/Factory.cpp +# COMMENT "Run include-what-you-use") +# add_dependencies(iwyu ${CMAKE_CURRENT_BINARY_DIR}/uscxml/config.h) +# # message(FATAL_ERROR "asdf") +#endif() + +############################################################ # Some concluding remarks ############################################################ @@ -894,11 +950,19 @@ if (BUILD_SHARED_LIBS AND BUILD_BINDINGS) endif() message(STATUS "General information:") -message(STATUS " Build type ..................... : ${CMAKE_BUILD_TYPE}") +message(STATUS " Build type ..................... : ${CMAKE_BUILD_TYPE} for ${USCXML_PLATFORM_ID}") if (BUILD_SHARED_LIBS) - message(STATUS " Building library as ............ : SHARED") + if (BUILD_AS_PLUGINS) + message(STATUS " Building library as ............ : SHARED with plugins") + else() + message(STATUS " Building library as ............ : SHARED without plugins") + endif() else() - message(STATUS " Building library as ............ : STATIC") + if (BUILD_AS_PLUGINS) + message(STATUS " Building library as ............ : STATIC with plugins") + else() + message(STATUS " Building library as ............ : STATIC without plugins") + endif() endif() if (BUILD_PREFER_STATIC_LIBRARIES) |