diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/Platform/Darwin.cmake | 76 |
1 files changed, 26 insertions, 50 deletions
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index d0bb359..1482d76 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -52,24 +52,21 @@ if("${DARWIN_MAJOR_VERSION}" GREATER 8) set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") endif() -set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") -set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ") -set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") -set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") +foreach(lang C CXX OBJC OBJCXX) + set(CMAKE_${lang}_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") + set(CMAKE_${lang}_OSX_CURRENT_VERSION_FLAG "-current_version ") + set(CMAKE_${lang}_LINK_FLAGS "-Wl,-headerpad_max_install_names") -set(CMAKE_C_LINK_FLAGS "-Wl,-headerpad_max_install_names") -set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names") + if(HAVE_FLAG_SEARCH_PATHS_FIRST) + set(CMAKE_${lang}_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_${lang}_LINK_FLAGS}") + endif() -if(HAVE_FLAG_SEARCH_PATHS_FIRST) - set(CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}") - set(CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}") -endif() + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names") + set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names") + set(CMAKE_SHARED_MODULE_LOADER_${lang}_FLAG "-Wl,-bundle_loader,") +endforeach() set(CMAKE_PLATFORM_HAS_INSTALLNAME 1) -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names") -set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names") -set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") -set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a") # hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree @@ -84,12 +81,6 @@ endif() # Enable shared library versioning. set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name") -# Xcode does not support -isystem yet. -if(XCODE) - set(CMAKE_INCLUDE_SYSTEM_FLAG_C) - set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX) -endif() - if("${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5") # Need to list dependent shared libraries on link line. When building # with -isysroot (for universal binaries), the linker always looks for @@ -98,40 +89,25 @@ if("${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5") set(CMAKE_LINK_DEPENDENT_LIBRARY_FILES 1) endif() -set(CMAKE_C_CREATE_SHARED_LIBRARY - "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") -set(CMAKE_CXX_CREATE_SHARED_LIBRARY - "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") -set(CMAKE_Fortran_CREATE_SHARED_LIBRARY - "<CMAKE_Fortran_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") - -set(CMAKE_CXX_CREATE_SHARED_MODULE - "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>") - -set(CMAKE_C_CREATE_SHARED_MODULE - "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>") - -set(CMAKE_Fortran_CREATE_SHARED_MODULE - "<CMAKE_Fortran_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CREATE_Fortran_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>") +foreach(lang C CXX Fortran OBJC OBJCXX) + # Xcode does not support -isystem yet. + if(XCODE) + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang}) + endif() -set(CMAKE_C_CREATE_MACOSX_FRAMEWORK - "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") -set(CMAKE_CXX_CREATE_MACOSX_FRAMEWORK - "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY + "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") -set(CMAKE_OBJC_CREATE_MACOSX_FRAMEWORK - "<CMAKE_OBJC_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_OBJC_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") + set(CMAKE_${lang}_CREATE_SHARED_MODULE + "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>") -set(CMAKE_OBJCXX_CREATE_MACOSX_FRAMEWORK - "<CMAKE_OBJCXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_OBJCXX_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") + set(CMAKE_${lang}_CREATE_MACOSX_FRAMEWORK + "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") -# Set default framework search path flag for languages known to use a -# preprocessor that may find headers in frameworks. -set(CMAKE_C_FRAMEWORK_SEARCH_FLAG -F) -set(CMAKE_CXX_FRAMEWORK_SEARCH_FLAG -F) -set(CMAKE_OBJC_FRAMEWORK_SEARCH_FLAG -F) -set(CMAKE_OBJCXX_FRAMEWORK_SEARCH_FLAG -F) -set(CMAKE_Fortran_FRAMEWORK_SEARCH_FLAG -F) + # Set default framework search path flag for languages known to use a + # preprocessor that may find headers in frameworks. + set(CMAKE_${lang}_FRAMEWORK_SEARCH_FLAG -F) +endforeach() # default to searching for frameworks first if(NOT DEFINED CMAKE_FIND_FRAMEWORK) |