From 3c77873b0ece124aa0e3756fef1a4cf76af6b010 Mon Sep 17 00:00:00 2001 From: Heinrich Janzing Date: Thu, 5 Jan 2017 09:19:19 +0100 Subject: [PATCH] CMake: allow disabling the intermediate objects target (cryptopp-object). Targets with only object inputs do not work correctly with some generators (like Xcode, see issue #355). Defining these directly in terms of the source code files (rather than a reused set of object files) allows correct builds in such cases. This can now be controlled through a new option USE_INTERMEDIATE_OBJECTS_TARGET which defaults to ON. --- CMakeLists.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 641fb8f8..c9a122a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,12 @@ option(BUILD_STATIC "Build static library" ON) option(BUILD_SHARED "Build shared library" ON) option(BUILD_TESTING "Build library tests" ON) option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF) +option(USE_INTERMEDIATE_OBJECTS_TARGET "Use a common intermediate objects target for the static and shared library targets" ON) + +if(CMAKE_VERSION VERSION_LESS 2.8.8 AND USE_INTERMEDIATE_OBJECTS_TARGET) + message(STATUS "Forcing USE_INTERMEDIATE_OBJECTS_TARGET to OFF - requires CMake >= 2.8.8") + set(USE_INTERMEDIATE_OBJECTS_TARGET OFF CACHE BOOL "Use a common intermediate objects target for the static and shared library targets" FORCE) +endif() option(DISABLE_ASM "Disable ASM" OFF) option(DISABLE_SSSE3 "Disable SSSE3" OFF) @@ -237,12 +243,12 @@ if(CMAKE_VERSION VERSION_LESS 2.8.12) include_directories("${CMAKE_CURRENT_SOURCE_DIR}") endif() -if(NOT CMAKE_VERSION VERSION_LESS 2.8.8) +if(USE_INTERMEDIATE_OBJECTS_TARGET) add_library(cryptopp-object OBJECT ${cryptopp_SOURCES}) endif() if (BUILD_STATIC) - if(NOT CMAKE_VERSION VERSION_LESS 2.8.8) + if(USE_INTERMEDIATE_OBJECTS_TARGET) add_library(cryptopp-static STATIC $) else() add_library(cryptopp-static STATIC ${cryptopp_SOURCES}) @@ -254,7 +260,7 @@ if (BUILD_STATIC) endif() if (BUILD_SHARED) - if(NOT CMAKE_VERSION VERSION_LESS 2.8.8) + if(USE_INTERMEDIATE_OBJECTS_TARGET) add_library(cryptopp-shared SHARED $) else() add_library(cryptopp-shared SHARED ${cryptopp_SOURCES})