|
@@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
|
|
|
|
|
|
project(JoltPhysics CXX)
|
|
|
|
|
|
+# Ability to turn ON/OFF individual applications
|
|
|
+option(TARGET_UNIT_TESTS "Build Unit Tests" ON)
|
|
|
+option(TARGET_HELLO_WORLD "Build Hello World" ON)
|
|
|
+option(TARGET_PERFORMANCE_TEST "Build Performance Test" ON)
|
|
|
+
|
|
|
# Select X86 processor features to use (if everything is off it will be SSE4.1 compatible)
|
|
|
option(USE_SSE4_2 "Enable SSE4.2" ON)
|
|
|
option(USE_AVX "Enable AVX" ON)
|
|
@@ -13,7 +18,7 @@ option(USE_FMADD "Enable FMADD" ON)
|
|
|
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
|
|
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Distribution")
|
|
|
-elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
|
+elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
|
|
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;ReleaseASAN;ReleaseUBSAN;ReleaseCoverage;Distribution")
|
|
|
endif()
|
|
|
|
|
@@ -93,7 +98,7 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASEUBSAN "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LIBPATH:${CLANG_LIB_PATH}")
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASECOVERAGE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LIBPATH:${CLANG_LIB_PATH}")
|
|
|
endif()
|
|
|
-elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
|
|
+elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "iOS")
|
|
|
# Set general compiler flags (do not use -ffast-math since it cannot be turned off in a single compilation unit)
|
|
|
set(CMAKE_CXX_FLAGS "-g -std=c++17 -I. -Wall -Werror")
|
|
|
|
|
@@ -152,39 +157,57 @@ set(PHYSICS_REPO_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../)
|
|
|
|
|
|
# Make Jolt Library
|
|
|
include(${PHYSICS_REPO_ROOT}/Jolt/Jolt.cmake)
|
|
|
-
|
|
|
-# Create UnitTests executable
|
|
|
-include(${PHYSICS_REPO_ROOT}/UnitTests/UnitTests.cmake)
|
|
|
-add_executable(UnitTests ${UNIT_TESTS_SRC_FILES})
|
|
|
-target_include_directories(UnitTests PUBLIC ${JOLT_PHYSICS_ROOT} ${UNIT_TESTS_ROOT})
|
|
|
-target_link_libraries (UnitTests LINK_PUBLIC Jolt)
|
|
|
-if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
|
|
- target_link_options(UnitTests PUBLIC "/SUBSYSTEM:CONSOLE")
|
|
|
+if (IOS)
|
|
|
+ # Ensure that we enable SSE4.2 for the x86_64 build, CMAKE_SYSTEM_PROCESSOR is not set for iOS
|
|
|
+ set_property(TARGET Jolt PROPERTY XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=x86_64] "$(inherited) -msse4.2 -mpopcnt")
|
|
|
endif()
|
|
|
|
|
|
-# Register unit tests as a test so that it can be run with:
|
|
|
-# ctest --output-on-failure
|
|
|
-enable_testing()
|
|
|
-add_test(UnitTests UnitTests)
|
|
|
+if (TARGET_UNIT_TESTS)
|
|
|
+ # Create UnitTests executable
|
|
|
+ include(${PHYSICS_REPO_ROOT}/UnitTests/UnitTests.cmake)
|
|
|
+ add_executable(UnitTests ${UNIT_TESTS_SRC_FILES})
|
|
|
+ target_include_directories(UnitTests PUBLIC ${JOLT_PHYSICS_ROOT} ${UNIT_TESTS_ROOT})
|
|
|
+ target_link_libraries (UnitTests LINK_PUBLIC Jolt)
|
|
|
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
|
|
+ target_link_options(UnitTests PUBLIC "/SUBSYSTEM:CONSOLE")
|
|
|
+ endif()
|
|
|
+ if (IOS)
|
|
|
+ # Set the bundle information
|
|
|
+ set_property(TARGET UnitTests PROPERTY MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/iOS/UnitTestsInfo.plist")
|
|
|
+ set_property(TARGET UnitTests PROPERTY XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.joltphysics.unittests")
|
|
|
+
|
|
|
+ # Ensure that we enable SSE4.2 for the x86_64 build, CMAKE_SYSTEM_PROCESSOR is not set for iOS
|
|
|
+ set_property(TARGET UnitTests PROPERTY XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=x86_64] "$(inherited) -msse4.2 -mpopcnt")
|
|
|
+ endif()
|
|
|
+
|
|
|
+ # Register unit tests as a test so that it can be run with:
|
|
|
+ # ctest --output-on-failure
|
|
|
+ enable_testing()
|
|
|
+ add_test(UnitTests UnitTests)
|
|
|
+endif()
|
|
|
|
|
|
-# Example 'Hello World' application
|
|
|
-include(${PHYSICS_REPO_ROOT}/HelloWorld/HelloWorld.cmake)
|
|
|
-add_executable(HelloWorld ${HELLO_WORLD_SRC_FILES})
|
|
|
-target_include_directories(HelloWorld PUBLIC ${JOLT_PHYSICS_ROOT} ${HELLO_WORLD_ROOT})
|
|
|
-target_link_libraries (HelloWorld LINK_PUBLIC Jolt)
|
|
|
-if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
|
|
- target_link_options(HelloWorld PUBLIC "/SUBSYSTEM:CONSOLE")
|
|
|
+if (TARGET_HELLO_WORLD)
|
|
|
+ # Example 'Hello World' application
|
|
|
+ include(${PHYSICS_REPO_ROOT}/HelloWorld/HelloWorld.cmake)
|
|
|
+ add_executable(HelloWorld ${HELLO_WORLD_SRC_FILES})
|
|
|
+ target_include_directories(HelloWorld PUBLIC ${JOLT_PHYSICS_ROOT} ${HELLO_WORLD_ROOT})
|
|
|
+ target_link_libraries (HelloWorld LINK_PUBLIC Jolt)
|
|
|
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
|
|
+ target_link_options(HelloWorld PUBLIC "/SUBSYSTEM:CONSOLE")
|
|
|
+ endif()
|
|
|
endif()
|
|
|
|
|
|
-# Performance Test application
|
|
|
-include(${PHYSICS_REPO_ROOT}/PerformanceTest/PerformanceTest.cmake)
|
|
|
-add_executable(PerformanceTest ${PERFORMANCE_TEST_SRC_FILES})
|
|
|
-target_include_directories(PerformanceTest PUBLIC ${JOLT_PHYSICS_ROOT} ${PERFORMANCE_TEST_ROOT})
|
|
|
-target_link_libraries (PerformanceTest LINK_PUBLIC Jolt)
|
|
|
-if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
|
|
- target_link_options(PerformanceTest PUBLIC "/SUBSYSTEM:CONSOLE")
|
|
|
+if (TARGET_PERFORMANCE_TEST)
|
|
|
+ # Performance Test application
|
|
|
+ include(${PHYSICS_REPO_ROOT}/PerformanceTest/PerformanceTest.cmake)
|
|
|
+ add_executable(PerformanceTest ${PERFORMANCE_TEST_SRC_FILES})
|
|
|
+ target_include_directories(PerformanceTest PUBLIC ${JOLT_PHYSICS_ROOT} ${PERFORMANCE_TEST_ROOT})
|
|
|
+ target_link_libraries (PerformanceTest LINK_PUBLIC Jolt)
|
|
|
+ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
|
|
+ target_link_options(PerformanceTest PUBLIC "/SUBSYSTEM:CONSOLE")
|
|
|
+ endif()
|
|
|
+ set_property(TARGET PerformanceTest PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PHYSICS_REPO_ROOT}")
|
|
|
endif()
|
|
|
-set_property(TARGET PerformanceTest PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PHYSICS_REPO_ROOT}")
|
|
|
|
|
|
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
|
|
# Windows only targets
|