|
@@ -79,6 +79,30 @@ if(NOT APPLE_IOS AND NOT ANDROID)
|
|
|
option(ENABLE_MONOLITHIC_INSTALL "Install everything in single directory on Linux and Mac" OFF)
|
|
|
endif()
|
|
|
|
|
|
+# On Linux, use -DCMAKE_CXX_COMPILER_LAUNCHER=ccache instead.
|
|
|
+# The XCode and MSVC builds each require some more configuration, which is enabled by the following option:
|
|
|
+if(MSVC OR (CMAKE_GENERATOR STREQUAL "Xcode"))
|
|
|
+ option(ENABLE_CCACHE "Speed up recompilation by caching previous compilations" ON)
|
|
|
+endif()
|
|
|
+
|
|
|
+if(ENABLE_CCACHE AND (CMAKE_GENERATOR STREQUAL "Xcode"))
|
|
|
+ find_program(CCACHE ccache REQUIRED)
|
|
|
+ if(CCACHE)
|
|
|
+ # https://stackoverflow.com/a/36515503/2278742
|
|
|
+ # Set up wrapper scripts
|
|
|
+ configure_file(xcode/launch-c.in xcode/launch-c)
|
|
|
+ configure_file(xcode/launch-cxx.in xcode/launch-cxx)
|
|
|
+ execute_process(COMMAND chmod a+rx
|
|
|
+ "${CMAKE_BINARY_DIR}/xcode/launch-c"
|
|
|
+ "${CMAKE_BINARY_DIR}/xcode/launch-cxx")
|
|
|
+ # Set Xcode project attributes to route compilation through our scripts
|
|
|
+ set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/xcode/launch-c")
|
|
|
+ set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/xcode/launch-cxx")
|
|
|
+ set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/xcode/launch-c")
|
|
|
+ set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/xcode/launch-cxx")
|
|
|
+ endif()
|
|
|
+endif()
|
|
|
+
|
|
|
# Allow to pass package name from Travis CI
|
|
|
set(PACKAGE_NAME_SUFFIX "" CACHE STRING "Suffix for CPack package name")
|
|
|
set(PACKAGE_FILE_NAME "" CACHE STRING "Override for CPack package filename")
|
|
@@ -237,6 +261,23 @@ if(MINGW OR MSVC)
|
|
|
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
|
|
|
|
|
if(MSVC)
|
|
|
+ if(ENABLE_CCACHE)
|
|
|
+ # https://github.com/ccache/ccache/discussions/1154#discussioncomment-3611387
|
|
|
+ find_program(CCACHE ccache REQUIRED)
|
|
|
+ if (CCACHE)
|
|
|
+ file(COPY_FILE
|
|
|
+ ${CCACHE} ${CMAKE_BINARY_DIR}/cl.exe
|
|
|
+ ONLY_IF_DIFFERENT)
|
|
|
+
|
|
|
+ set(CMAKE_VS_GLOBALS
|
|
|
+ "CLToolExe=cl.exe"
|
|
|
+ "CLToolPath=${CMAKE_BINARY_DIR}"
|
|
|
+ "TrackFileAccess=false"
|
|
|
+ "UseMultiToolTask=true"
|
|
|
+ )
|
|
|
+ endif()
|
|
|
+ endif()
|
|
|
+
|
|
|
add_definitions(-DBOOST_ALL_NO_LIB)
|
|
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
|
|
set(Boost_USE_STATIC_LIBS OFF)
|