From 97b6eb8370c4e1bdba4870aca96a8e4d8c9d0269 Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Mon, 19 Sep 2016 05:11:48 -0700 Subject: [PATCH 01/13] Fix InstallHeaders so it works properly with generated sources --- standard/InstallHeaders.cmake | 50 ++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/standard/InstallHeaders.cmake b/standard/InstallHeaders.cmake index 0bc6de3f6..130231b3a 100644 --- a/standard/InstallHeaders.cmake +++ b/standard/InstallHeaders.cmake @@ -15,7 +15,7 @@ function(install_headers) set(multiValueArgs) cmake_parse_arguments(opt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - + string(TOLOWER LOWERNAME CMAKE_PROJECT_NAME) default_value(opt_DESTINATION include/${LOWERNAME}) @@ -28,15 +28,47 @@ function(install_headers) if(NOT ${opt_NOEXCLUDE_STDAFX} AND ${src} STREQUAL "stdafx.h") continue() endif() - get_filename_component(src_ext ${src} EXT) - if(src_ext STREQUAL ".h") - get_filename_component(src_rel ${src} DIRECTORY) - install( - FILES ${src} - DESTINATION ${opt_DESTINATION}/${src_rel} - ${opt_UNPARSED_ARGUMENTS} - ) + if(NOT src_ext STREQUAL ".h") + continue() endif() + + # Need to make the path absolute. We first look in the source directory, + # then we look in the binary directory, but only if the path is relative. + if(NOT IS_ABSOLUTE ${src}) + get_filename_component(src_src ${src} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + get_filename_component(src_bin ${src} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}) + if(EXISTS ${src_src}) + set(src ${src_src}) + elseif(EXISTS ${src_bin}) + set(src ${src_bin}) + else() + message(FATAL_ERROR "Could not find input header file ${src}") + endif() + endif() + + # We find out what directory part the file is in, we want the shortest + # relative path on the assumption that the file will be most properly + # located in the directory whose relative address is the shortest. + file(RELATIVE_PATH src_rel ${CMAKE_SOURCE_DIR} ${src}) + get_filename_component(src_rel ${src_rel} DIRECTORY) + string(LENGTH ${src_rel} src_rel_len) + + file(RELATIVE_PATH bin_rel ${CMAKE_BINARY_DIR} ${src}) + get_filename_component(bin_rel ${bin_rel} DIRECTORY) + string(LENGTH ${bin_rel} bin_rel_len) + + if(src_rel_len LESS bin_rel_len) + set(actual_rel ${src_rel}) + else() + set(actual_rel ${bin_rel}) + endif() + + get_filename_component(src_ext ${src} EXT) + install( + FILES ${src} + DESTINATION ${opt_DESTINATION}/${actual_rel} + ${opt_UNPARSED_ARGUMENTS} + ) endforeach() endfunction() From b732aea8813db9f042d697d4f26287ed7d230e2c Mon Sep 17 00:00:00 2001 From: James Donald Date: Mon, 26 Sep 2016 10:12:36 -0700 Subject: [PATCH 02/13] Set sysroot/target defaults for Xcode 7.3 and 8 --- standard/StandardProject.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index cbf8a45b6..60d823bae 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -104,6 +104,21 @@ function(standard_project_preinit) set(CMAKE_CXX_STANDARD_REQUIRED ON PARENT_SCOPE) set(CMAKE_CXX_EXTENSIONS OFF PARENT_SCOPE) + if(APPLE AND NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm")) + if(NOT CMAKE_OSX_SYSROOT) + set(_developer_sdk_version 10.11) + # CLANG_VERSION requires a sysroot to obtain, so resort to execute_process() here + execute_process(COMMAND clang -v ERROR_VARIABLE _clang_version) + if(_clang_version MATCHES "clang-8") + set(_developer_sdk_version 10.12) + endif() + set(CMAKE_OSX_SYSROOT "macosx${_developer_sdk_version}" CACHE STRING "Mac OS X build environment" FORCE) + endif() + if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Mac OS X deployment target" FORCE) + endif() + endif() + #CMAKE_OSX_DEPLOYMENT_TARGET < 10.9 implies -stdlib=libstdc++, which doesn't have #complete c++11 support. override with libc++ if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.9) From e132a0d305eb6243e44c8054ea43c0289be28ef4 Mon Sep 17 00:00:00 2001 From: hham Date: Mon, 26 Sep 2016 16:50:18 -0700 Subject: [PATCH 03/13] Fix a typo --- standard/StandardProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index 60d823bae..e03a93cc0 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -53,7 +53,7 @@ function(standard_project_preinit) if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm") set(standard_BUILD_ARM ON PARENT_SCOPE) set(standard_BUILD_ARCHITECTURES "arm" PARENT_SCOPE) - set(standard_BUILD_64 OFFPARENT_SCOPE) + set(standard_BUILD_64 OFF PARENT_SCOPE) elseif(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64;i386") set(standard_BUILD_ARCHITECTURES x64 x86 PARENT_SCOPE) set(standard_BUILD_64 ON PARENT_SCOPE) From c5bc33670aae71c1b6f9f4f8471c79d402092db7 Mon Sep 17 00:00:00 2001 From: James Donald Date: Tue, 27 Sep 2016 09:13:33 -0700 Subject: [PATCH 04/13] Fix capitalization in comment --- standard/StandardProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index e03a93cc0..2e20dfc1d 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -88,7 +88,7 @@ function(standard_project_preinit) set(CMAKE_DEBUG_POSTFIX "d${CMAKE_DEBUG_POSTFIX}") set(CMAKE_DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX} PARENT_SCOPE) - # 64-bit installations should suffix with 64 regardless of the CPU type (arm or intel) + # 64-bit installations should suffix with 64 regardless of the CPU type (ARM or Intel) if(CMAKE_SIZEOF_VOID_P EQUAL 8) foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) string(TOUPPER ${config} config) From 32ed0a5ec27cd6be28f2fe85204f34658a7fd909 Mon Sep 17 00:00:00 2001 From: James Donald Date: Tue, 27 Sep 2016 09:15:57 -0700 Subject: [PATCH 05/13] Fix spelling of compatibility via aspell --- standard/StandardProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index 2e20dfc1d..b1b2aad86 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -14,7 +14,7 @@ does the following: * Enforces the project has a VERSION set. ]] -include (CMakeParseArguments) #Backwards compatibilty +include (CMakeParseArguments) #Backwards compatibility #This must be a macro since project defines scope-local variables #that we generally rely on being in the root context. From 97a9db41d5f8e828ee14dc9d486e413a97dfd8eb Mon Sep 17 00:00:00 2001 From: James Donald Date: Tue, 27 Sep 2016 09:16:33 -0700 Subject: [PATCH 06/13] Remove inconsistent space --- standard/StandardProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index b1b2aad86..8011fdd2a 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -14,7 +14,7 @@ does the following: * Enforces the project has a VERSION set. ]] -include (CMakeParseArguments) #Backwards compatibility +include(CMakeParseArguments) #Backwards compatibility #This must be a macro since project defines scope-local variables #that we generally rely on being in the root context. From 47ddb778a2710ab53f2c360fbd107fcf6b84ce76 Mon Sep 17 00:00:00 2001 From: James Donald Date: Tue, 27 Sep 2016 09:17:42 -0700 Subject: [PATCH 07/13] Remove inconsistent double-pound --- standard/StandardProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index 8011fdd2a..152a67cbc 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -128,7 +128,7 @@ function(standard_project_preinit) endfunction() function(standard_project_postinit) - ##Post-initialization steps. All of these depend on project() having been called. + #Post-initialization steps. All of these depend on project() having been called. include(CTest) if(CMAKE_COMPILER_IS_GNUCC) From 908ad9926612705ebb0fcb68403be8fe14ddb24b Mon Sep 17 00:00:00 2001 From: James Donald Date: Tue, 27 Sep 2016 09:20:52 -0700 Subject: [PATCH 08/13] Fix spacing and more consistency in comment style --- standard/StandardProject.cmake | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index 152a67cbc..9c5b312bc 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -4,7 +4,7 @@ in a particular order around project setup. This function wraps project() and does the following: * Changes CMake around so that the output variables follow the /bin and /lib output - directory convention popular on Gnu. + directory convention popular on GNU. * Ensures that ARM and 64-bit code are built as position-independent code * Verifies that the compiler actually supports C++11 * Sets the correct flags to enable C++11 on all platforms @@ -14,10 +14,10 @@ does the following: * Enforces the project has a VERSION set. ]] -include(CMakeParseArguments) #Backwards compatibility +include(CMakeParseArguments) # Backwards compatibility -#This must be a macro since project defines scope-local variables -#that we generally rely on being in the root context. +# This must be a macro since project defines scope-local variables +# that we generally rely on being in the root context. macro(standard_project project_name) cmake_parse_arguments(standard "" "VERSION" "LANGUAGES" ${ARGN}) if(NOT standard_VERSION) @@ -46,10 +46,10 @@ function(standard_project_preinit) endif() endif() - #These do not strictly *have* to be set prior to project, but they can be so we will - - # Need to classify the architecture before we run anything else, this lets us easily configure the - # find version file based on what the architecture was actually built to be + # These do not strictly *have* to be set prior to project, but they can be so we will + # Need to classify the architecture before we run anything else, this lets us easily + # configure the find version file based on what the architecture was actually built to + # be. if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm") set(standard_BUILD_ARM ON PARENT_SCOPE) set(standard_BUILD_ARCHITECTURES "arm" PARENT_SCOPE) @@ -66,7 +66,7 @@ function(standard_project_preinit) endif() message(STATUS "Using architecture: ${standard_BUILD_ARCHITECTURES}") - # All of our binaries go to one place: The binaries output directory. We only want to tinker + # All of our binaries go to one place: The binaries output directory. We only want to tinker # with this if we're building by ourselves, otherwise we just do whatever the enclosing project # wants us to do. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin PARENT_SCOPE) @@ -119,8 +119,8 @@ function(standard_project_preinit) endif() endif() - #CMAKE_OSX_DEPLOYMENT_TARGET < 10.9 implies -stdlib=libstdc++, which doesn't have - #complete c++11 support. override with libc++ + # CMAKE_OSX_DEPLOYMENT_TARGET < 10.9 implies -stdlib=libstdc++, which doesn't have + # complete c++11 support. override with libc++ if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.9) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" PARENT_SCOPE) endif() @@ -128,7 +128,7 @@ function(standard_project_preinit) endfunction() function(standard_project_postinit) - #Post-initialization steps. All of these depend on project() having been called. + # Post-initialization steps. All of these depend on project() having been called. include(CTest) if(CMAKE_COMPILER_IS_GNUCC) From 993d561d299e22b02df0f21bcb8a7ecf3ee7fc58 Mon Sep 17 00:00:00 2001 From: James Donald Date: Tue, 27 Sep 2016 09:25:32 -0700 Subject: [PATCH 09/13] Comment style consistency in other files --- standard/standard-configVersion.cmake.in | 2 +- standard/toolchain-android.cmake | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/standard/standard-configVersion.cmake.in b/standard/standard-configVersion.cmake.in index 73741a679..0796e2635 100644 --- a/standard/standard-configVersion.cmake.in +++ b/standard/standard-configVersion.cmake.in @@ -73,7 +73,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") endif() endif() -if(NOT @ARG_VERSION_PRERELEASE@ STREQUAL "") #handle prerelease versions +if(NOT @ARG_VERSION_PRERELEASE@ STREQUAL "") # handle prerelease versions set(PACKAGE_FIND_VERSION_PRERELEASE "${@ARG_NAME@_FIND_VERSION_PRERELEASE}") if(NOT PACKAGE_FIND_VERSION_PRERELEASE) set(PACKAGE_VERSION_COMPATIBLE FALSE) diff --git a/standard/toolchain-android.cmake b/standard/toolchain-android.cmake index 32f0b4462..dcb9200f8 100644 --- a/standard/toolchain-android.cmake +++ b/standard/toolchain-android.cmake @@ -2,9 +2,9 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_SYSTEM_VERSION 1) -#For reasons beyond my comprehension, this file is parsed multiple times -#and in some of them, cache variables are not preserved so we have to store -#this in an environmental variable... +# For reasons beyond my comprehension, this file is parsed multiple times +# and in some of them, cache variables are not preserved so we have to store +# this in an environmental variable... if(NOT LLVM_ANDROID_TOOLCHAIN_DIR) set(LLVM_ANDROID_TOOLCHAIN_DIR $ENV{LLVM_ANDROID_TOOLCHAIN_DIR}) else() @@ -12,7 +12,7 @@ else() endif() find_path(ANDROID_NDK_ROOT bin/${ANDROID_NDK_TOOL_PREFIX}-gcc${_exe_suffix} PATHS - ${LLVM_ANDROID_TOOLCHAIN_DIR}${_ndk_suffix} #legacy variable + ${LLVM_ANDROID_TOOLCHAIN_DIR}${_ndk_suffix} # legacy variable /opt/android-standalone-toolchain${_ndk_suffix} ${LLVM_ANDROID_TOOLCHAIN_DIR} /opt/android-standalone-toolchain From a478db63676aef5b4adf16dcc6f71baa0bac1b49 Mon Sep 17 00:00:00 2001 From: James Donald Date: Tue, 27 Sep 2016 09:28:50 -0700 Subject: [PATCH 10/13] Capitalize C++11 --- standard/StandardProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index 9c5b312bc..b020ca3c2 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -120,7 +120,7 @@ function(standard_project_preinit) endif() # CMAKE_OSX_DEPLOYMENT_TARGET < 10.9 implies -stdlib=libstdc++, which doesn't have - # complete c++11 support. override with libc++ + # complete C++11 support. Override with libc++ if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.9) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++" PARENT_SCOPE) endif() From 1c6756538f0cde9741cac91d4db380b97987b555 Mon Sep 17 00:00:00 2001 From: James Donald Date: Tue, 27 Sep 2016 18:08:37 -0700 Subject: [PATCH 11/13] Fix InstallHeaders to use CURRENT source/bin dir --- standard/InstallHeaders.cmake | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/standard/InstallHeaders.cmake b/standard/InstallHeaders.cmake index 130231b3a..819335905 100644 --- a/standard/InstallHeaders.cmake +++ b/standard/InstallHeaders.cmake @@ -50,18 +50,20 @@ function(install_headers) # We find out what directory part the file is in, we want the shortest # relative path on the assumption that the file will be most properly # located in the directory whose relative address is the shortest. - file(RELATIVE_PATH src_rel ${CMAKE_SOURCE_DIR} ${src}) + file(RELATIVE_PATH src_rel ${CMAKE_CURRENT_SOURCE_DIR} ${src}) get_filename_component(src_rel ${src_rel} DIRECTORY) - string(LENGTH ${src_rel} src_rel_len) + if(src_rel) + string(LENGTH ${src_rel} src_rel_len) + set(actual_rel ${src_rel}) + endif() - file(RELATIVE_PATH bin_rel ${CMAKE_BINARY_DIR} ${src}) + file(RELATIVE_PATH bin_rel ${CMAKE_CURRENT_BINARY_DIR} ${src}) get_filename_component(bin_rel ${bin_rel} DIRECTORY) - string(LENGTH ${bin_rel} bin_rel_len) - - if(src_rel_len LESS bin_rel_len) - set(actual_rel ${src_rel}) - else() - set(actual_rel ${bin_rel}) + if(bin_rel) + string(LENGTH ${bin_rel} bin_rel_len) + if(src_rel AND bin_rel_len LESS src_rel_len) + set(actual_rel ${bin_rel}) + endif() endif() get_filename_component(src_ext ${src} EXT) From 308abdc60130463a5b8e83094e5f209df44ae315 Mon Sep 17 00:00:00 2001 From: James Donald Date: Tue, 27 Sep 2016 22:48:15 -0700 Subject: [PATCH 12/13] Don't set either variable on Xcode 6 --- standard/StandardProject.cmake | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index b020ca3c2..d3f69c103 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -106,15 +106,18 @@ function(standard_project_preinit) if(APPLE AND NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm")) if(NOT CMAKE_OSX_SYSROOT) - set(_developer_sdk_version 10.11) # CLANG_VERSION requires a sysroot to obtain, so resort to execute_process() here execute_process(COMMAND clang -v ERROR_VARIABLE _clang_version) - if(_clang_version MATCHES "clang-8") + if(_clang_version MATCHES "clang-7") + set(_developer_sdk_version 10.11) + elseif(_clang_version MATCHES "clang-8") set(_developer_sdk_version 10.12) endif() - set(CMAKE_OSX_SYSROOT "macosx${_developer_sdk_version}" CACHE STRING "Mac OS X build environment" FORCE) + if(_developer_sdk_version) + set(CMAKE_OSX_SYSROOT "macosx${_developer_sdk_version}" CACHE STRING "Mac OS X build environment" FORCE) + endif() endif() - if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) + if(_developer_sdk_version AND NOT CMAKE_OSX_DEPLOYMENT_TARGET) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Mac OS X deployment target" FORCE) endif() endif() From 67f07c80b84dd60083f5a4133d24a1405dd8575b Mon Sep 17 00:00:00 2001 From: James Donald Date: Tue, 27 Sep 2016 22:49:17 -0700 Subject: [PATCH 13/13] Move clause inside so only affects Xcode 7+ --- standard/StandardProject.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index d3f69c103..19a657081 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -115,11 +115,11 @@ function(standard_project_preinit) endif() if(_developer_sdk_version) set(CMAKE_OSX_SYSROOT "macosx${_developer_sdk_version}" CACHE STRING "Mac OS X build environment" FORCE) + if(NOT CMAKE_OSX_DEPLOYMENT_TARGET) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Mac OS X deployment target" FORCE) + endif() endif() endif() - if(_developer_sdk_version AND NOT CMAKE_OSX_DEPLOYMENT_TARGET) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Mac OS X deployment target" FORCE) - endif() endif() # CMAKE_OSX_DEPLOYMENT_TARGET < 10.9 implies -stdlib=libstdc++, which doesn't have