From 580a84963bb5f4d7e5e40473b6b89524d4b94244 Mon Sep 17 00:00:00 2001 From: James Donald Date: Mon, 3 Oct 2016 20:55:35 -0700 Subject: [PATCH 1/5] No length comparisons for header install --- standard/InstallHeaders.cmake | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/standard/InstallHeaders.cmake b/standard/InstallHeaders.cmake index 819335905..98298176e 100644 --- a/standard/InstallHeaders.cmake +++ b/standard/InstallHeaders.cmake @@ -40,31 +40,20 @@ function(install_headers) get_filename_component(src_bin ${src} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}) if(EXISTS ${src_src}) set(src ${src_src}) + file(RELATIVE_PATH src_rel ${CMAKE_CURRENT_SOURCE_DIR} ${src}) + get_filename_component(src_rel ${src_rel} DIRECTORY) + set(actual_rel ${src_rel}) elseif(EXISTS ${src_bin}) set(src ${src_bin}) + file(RELATIVE_PATH bin_rel ${CMAKE_CURRENT_BINARY_DIR} ${src}) + get_filename_component(bin_rel ${bin_rel} DIRECTORY) + set(actual_rel ${bin_rel}) 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_CURRENT_SOURCE_DIR} ${src}) - get_filename_component(src_rel ${src_rel} DIRECTORY) - if(src_rel) - string(LENGTH ${src_rel} src_rel_len) - set(actual_rel ${src_rel}) - endif() - file(RELATIVE_PATH bin_rel ${CMAKE_CURRENT_BINARY_DIR} ${src}) - get_filename_component(bin_rel ${bin_rel} DIRECTORY) - 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) install( From 1c425ef0b2d07f70e89e689865a3b01660015e98 Mon Sep 17 00:00:00 2001 From: James Donald Date: Mon, 3 Oct 2016 21:11:53 -0700 Subject: [PATCH 2/5] Default to Release build if CMAKE_BUILD_TYPE unspecified --- standard/StandardProject.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index 19a657081..68c646c0a 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -46,6 +46,10 @@ function(standard_project_preinit) endif() endif() + if(NOT MSVC AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release." FORCE) + 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 From 60eb4430a1eed0bbfe09bea0df8f9c41d9c45890 Mon Sep 17 00:00:00 2001 From: James Donald Date: Wed, 12 Oct 2016 09:26:23 -0700 Subject: [PATCH 3/5] Use full path to the OS X SDK --- standard/StandardProject.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index 19a657081..f86098f41 100644 --- a/standard/StandardProject.cmake +++ b/standard/StandardProject.cmake @@ -114,7 +114,7 @@ function(standard_project_preinit) set(_developer_sdk_version 10.12) endif() if(_developer_sdk_version) - set(CMAKE_OSX_SYSROOT "macosx${_developer_sdk_version}" CACHE STRING "Mac OS X build environment" FORCE) + set(CMAKE_OSX_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_developer_sdk_version}.sdk" 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() From 283295e96ce2227fff7384cd1fb66e31d904d38c Mon Sep 17 00:00:00 2001 From: Walter Gray Date: Wed, 12 Oct 2016 12:40:30 -0700 Subject: [PATCH 4/5] Remove duplicate code, clarify logic around extracting the install directory from the relative path --- standard/InstallHeaders.cmake | 39 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/standard/InstallHeaders.cmake b/standard/InstallHeaders.cmake index 98298176e..70362522f 100644 --- a/standard/InstallHeaders.cmake +++ b/standard/InstallHeaders.cmake @@ -33,32 +33,31 @@ function(install_headers) 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}) - file(RELATIVE_PATH src_rel ${CMAKE_CURRENT_SOURCE_DIR} ${src}) - get_filename_component(src_rel ${src_rel} DIRECTORY) - set(actual_rel ${src_rel}) - elseif(EXISTS ${src_bin}) - set(src ${src_bin}) - file(RELATIVE_PATH bin_rel ${CMAKE_CURRENT_BINARY_DIR} ${src}) - get_filename_component(bin_rel ${bin_rel} DIRECTORY) - set(actual_rel ${bin_rel}) - else() - message(FATAL_ERROR "Could not find input header file ${src}") - endif() + #When the path to the file is absolute, we don't know what we should be installing + #it relative to. Warn + if(IS_ABSOLUTE ${src}) + message(WARNING "Not sure where to install file with absolute path ${src}") + continue() endif() + #Determine which path the file is relative to and use intermediate directories as the install path + foreach(_search_dir "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") + get_filename_component(src_abs ${src} ABSOLUTE BASE_DIR ${_search_dir}) + if(EXISTS ${src_abs}) + set(src ${src_abs}) + file(RELATIVE_PATH containing_dir ${_search_dir} ${src}) + get_filename_component(containing_dir ${containing_dir} DIRECTORY) + break() + endif() + endforeach() + if(NOT EXISTS ${src_abs}) + message(FATAL_ERROR "Could not find input header file ${src}") + endif() - get_filename_component(src_ext ${src} EXT) install( FILES ${src} - DESTINATION ${opt_DESTINATION}/${actual_rel} + DESTINATION ${opt_DESTINATION}/${containing_dir} ${opt_UNPARSED_ARGUMENTS} ) endforeach() From be037bb563c4010226f870f1e77907ccd1cf485d Mon Sep 17 00:00:00 2001 From: James Donald Date: Wed, 12 Oct 2016 15:23:53 -0700 Subject: [PATCH 5/5] Restore comment spacing style --- standard/InstallHeaders.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/standard/InstallHeaders.cmake b/standard/InstallHeaders.cmake index 70362522f..23c9cf3f3 100644 --- a/standard/InstallHeaders.cmake +++ b/standard/InstallHeaders.cmake @@ -33,14 +33,14 @@ function(install_headers) continue() endif() - #When the path to the file is absolute, we don't know what we should be installing - #it relative to. Warn + # When the path to the file is absolute, we don't know what we should be installing + # it relative to. Warn if(IS_ABSOLUTE ${src}) message(WARNING "Not sure where to install file with absolute path ${src}") continue() endif() - #Determine which path the file is relative to and use intermediate directories as the install path + # Determine which path the file is relative to and use intermediate directories as the install path foreach(_search_dir "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}") get_filename_component(src_abs ${src} ABSOLUTE BASE_DIR ${_search_dir}) if(EXISTS ${src_abs})