diff --git a/standard/InstallHeaders.cmake b/standard/InstallHeaders.cmake index 819335905..23c9cf3f3 100644 --- a/standard/InstallHeaders.cmake +++ b/standard/InstallHeaders.cmake @@ -33,43 +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}) - 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_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}) + # 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() - 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}) + # 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() diff --git a/standard/StandardProject.cmake b/standard/StandardProject.cmake index 19a657081..fe66a8cc4 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 @@ -114,7 +118,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()