|
@@ -14,7 +14,9 @@ option(CROSS_PLATFORM_DETERMINISTIC "Cross platform deterministic" OFF)
|
|
|
# When turning this option on, the library will be compiled for ARM (aarch64-linux-gnu), requires compiling with clang
|
|
|
option(CROSS_COMPILE_ARM "Cross compile to aarch64-linux-gnu" OFF)
|
|
|
|
|
|
-# When turning this option on, the library will be compiled with interprocedural optimizations enabled, also known as link-time optimizations or link-time code generation
|
|
|
+# When turning this option on, the library will be compiled with interprocedural optimizations enabled, also known as link-time optimizations or link-time code generation.
|
|
|
+# Note that if you turn this on you need to use SET_INTERPROCEDURAL_OPTIMIZATION() or set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) to enable LTO specificly for your own project as well.
|
|
|
+# If you don't do this you may get an error: /usr/bin/ld: libJolt.a: error adding symbols: file format not recognized
|
|
|
option(INTERPROCEDURAL_OPTIMIZATION "Enable interprocedural optimizations" ON)
|
|
|
|
|
|
# When turning this on, in Debug and Release mode, the library will emit extra code to ensure that the 4th component of a 3-vector is kept the same as the 3rd component
|
|
@@ -143,24 +145,28 @@ elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQU
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread")
|
|
|
endif()
|
|
|
|
|
|
-set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF)
|
|
|
-set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DISTRIBUTION OFF)
|
|
|
+# Set linker flags
|
|
|
+set(CMAKE_EXE_LINKER_FLAGS_DISTRIBUTION "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
|
|
|
|
|
|
-# On ARM, whole program optimization triggers an internal compiler error during code gen, so we don't turn it on
|
|
|
-if (INTERPROCEDURAL_OPTIMIZATION AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM64") AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM"))
|
|
|
- include(CheckIPOSupported)
|
|
|
- check_ipo_supported(RESULT IS_IPO_SUPPORTED OUTPUT IPO_CHECK_OUTPUT)
|
|
|
+# Enable link time optimization in Release and Distribution mode if requested and available
|
|
|
+function(SET_INTERPROCEDURAL_OPTIMIZATION)
|
|
|
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF PARENT_SCOPE)
|
|
|
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DISTRIBUTION OFF PARENT_SCOPE)
|
|
|
|
|
|
- if (IS_IPO_SUPPORTED)
|
|
|
- set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
|
|
|
- set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DISTRIBUTION ON)
|
|
|
- else()
|
|
|
- message(WARNING "Interprocedural optimizations are not supported: ${IPO_CHECK_OUTPUT}")
|
|
|
- endif()
|
|
|
-endif()
|
|
|
+ # On ARM, whole program optimization triggers an internal compiler error during code gen, so we don't turn it on
|
|
|
+ if (INTERPROCEDURAL_OPTIMIZATION AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM64") AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM"))
|
|
|
+ include(CheckIPOSupported)
|
|
|
+ check_ipo_supported(RESULT IS_IPO_SUPPORTED OUTPUT IPO_CHECK_OUTPUT)
|
|
|
|
|
|
-# Set linker flags
|
|
|
-set(CMAKE_EXE_LINKER_FLAGS_DISTRIBUTION "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
|
|
|
+ if (IS_IPO_SUPPORTED)
|
|
|
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON PARENT_SCOPE)
|
|
|
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DISTRIBUTION ON PARENT_SCOPE)
|
|
|
+ else()
|
|
|
+ message(WARNING "Interprocedural optimizations are not supported: ${IPO_CHECK_OUTPUT}")
|
|
|
+ endif()
|
|
|
+ endif()
|
|
|
+endfunction()
|
|
|
+SET_INTERPROCEDURAL_OPTIMIZATION()
|
|
|
|
|
|
# Set repository root
|
|
|
set(PHYSICS_REPO_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../)
|