Răsfoiți Sursa

Using target_precompile_headers instead of manually specifying precompiled headers (#175)

Jorrit Rouwe 3 ani în urmă
părinte
comite
9171a12ea6

+ 1 - 1
Build/Android/UnitTests/build.gradle

@@ -35,7 +35,7 @@ android {
     externalNativeBuild {
         cmake {
             path file('src/main/cpp/CMakeLists.txt')
-            version '3.10.2'
+            version '3.18.1'
         }
     }
 

+ 5 - 4
Build/CMakeLists.txt

@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
 
 project(JoltPhysics CXX)
 
@@ -182,7 +182,8 @@ if (TARGET_UNIT_TESTS)
     include(${PHYSICS_REPO_ROOT}/UnitTests/UnitTests.cmake)
     add_executable(UnitTests ${UNIT_TESTS_SRC_FILES})
     target_include_directories(UnitTests PUBLIC ${UNIT_TESTS_ROOT})
-    target_link_libraries (UnitTests LINK_PUBLIC Jolt)
+    target_link_libraries(UnitTests LINK_PUBLIC Jolt)
+	target_precompile_headers(UnitTests PRIVATE ${JOLT_PHYSICS_ROOT}/Jolt.h)
     if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
         target_link_options(UnitTests PUBLIC "/SUBSYSTEM:CONSOLE")
     endif()
@@ -207,7 +208,7 @@ if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
 		include(${PHYSICS_REPO_ROOT}/HelloWorld/HelloWorld.cmake)
 		add_executable(HelloWorld ${HELLO_WORLD_SRC_FILES})
 		target_include_directories(HelloWorld PUBLIC ${HELLO_WORLD_ROOT})
-		target_link_libraries (HelloWorld LINK_PUBLIC Jolt)
+		target_link_libraries(HelloWorld LINK_PUBLIC Jolt)
 		if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
 			target_link_options(HelloWorld PUBLIC "/SUBSYSTEM:CONSOLE")
 		endif()
@@ -218,7 +219,7 @@ if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
 		include(${PHYSICS_REPO_ROOT}/PerformanceTest/PerformanceTest.cmake)
 		add_executable(PerformanceTest ${PERFORMANCE_TEST_SRC_FILES})
 		target_include_directories(PerformanceTest PUBLIC ${PERFORMANCE_TEST_ROOT})
-		target_link_libraries (PerformanceTest LINK_PUBLIC Jolt)
+		target_link_libraries(PerformanceTest LINK_PUBLIC Jolt)
 		if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
 			target_link_options(PerformanceTest PUBLIC "/SUBSYSTEM:CONSOLE")
 		endif()

+ 1 - 7
Jolt/Jolt.cmake

@@ -385,19 +385,13 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
 	set(JOLT_PHYSICS_SRC_FILES ${JOLT_PHYSICS_SRC_FILES} ${JOLT_PHYSICS_ROOT}/Jolt.natvis)
 endif()
 
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
-	# Enable Precompiled Headers for Jolt
-	set_source_files_properties(${JOLT_PHYSICS_SRC_FILES} PROPERTIES COMPILE_FLAGS "/YuJolt/Jolt.h")
-	set(JOLT_PHYSICS_SRC_FILES ${JOLT_PHYSICS_SRC_FILES} ${JOLT_PHYSICS_ROOT}/pch.cpp)	
-	set_source_files_properties(${JOLT_PHYSICS_ROOT}/pch.cpp PROPERTIES COMPILE_FLAGS "/YcJolt/Jolt.h")
-endif()
-
 # Group source files
 source_group(TREE ${JOLT_PHYSICS_ROOT} FILES ${JOLT_PHYSICS_SRC_FILES})
 
 # Create Jolt lib
 add_library(Jolt STATIC ${JOLT_PHYSICS_SRC_FILES})
 target_include_directories(Jolt PUBLIC ${PHYSICS_REPO_ROOT})
+target_precompile_headers(Jolt PRIVATE ${JOLT_PHYSICS_ROOT}/Jolt.h)
 target_compile_definitions(Jolt PUBLIC "$<$<CONFIG:Debug>:_DEBUG;JPH_PROFILE_ENABLED;JPH_DEBUG_RENDERER>")
 target_compile_definitions(Jolt PUBLIC "$<$<CONFIG:Release>:NDEBUG;JPH_PROFILE_ENABLED;JPH_DEBUG_RENDERER>")
 target_compile_definitions(Jolt PUBLIC "$<$<CONFIG:Distribution>:NDEBUG>")

+ 0 - 1
Jolt/pch.cpp

@@ -1 +0,0 @@
-#include <Jolt/Jolt.h>

+ 1 - 1
JoltViewer/JoltViewer.cmake

@@ -14,7 +14,7 @@ source_group(TREE ${JOLT_VIEWER_ROOT} FILES ${JOLT_VIEWER_SRC_FILES})
 # Create JoltViewer executable
 add_executable(JoltViewer ${JOLT_VIEWER_SRC_FILES})
 target_include_directories(JoltViewer PUBLIC ${JOLT_VIEWER_ROOT})
-target_link_libraries (JoltViewer LINK_PUBLIC TestFramework d3d12.lib shcore.lib)
+target_link_libraries(JoltViewer LINK_PUBLIC TestFramework d3d12.lib shcore.lib)
 
 # Set the correct working directory
 set_property(TARGET JoltViewer PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PHYSICS_REPO_ROOT}")

+ 1 - 8
Samples/Samples.cmake

@@ -203,20 +203,13 @@ set(SAMPLES_SRC_FILES
 	${SAMPLES_ROOT}/Utils/ShapeCreator.h
 )
 
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
-	# Enable Precompiled Headers for Samples
-	set_source_files_properties(${SAMPLES_SRC_FILES} PROPERTIES COMPILE_FLAGS "/YuTestFramework.h")
-	set(SAMPLES_SRC_FILES ${SAMPLES_SRC_FILES} ${SAMPLES_ROOT}/pch.cpp)
-	set_source_files_properties(${SAMPLES_ROOT}/pch.cpp PROPERTIES COMPILE_FLAGS "/YcTestFramework.h")
-endif()
-
 # Group source files
 source_group(TREE ${SAMPLES_ROOT} FILES ${SAMPLES_SRC_FILES})	
 
 # Create Samples executable
 add_executable(Samples  ${SAMPLES_SRC_FILES})
 target_include_directories(Samples PUBLIC ${SAMPLES_ROOT})
-target_link_libraries (Samples LINK_PUBLIC TestFramework d3d12.lib shcore.lib)
+target_link_libraries(Samples LINK_PUBLIC TestFramework d3d12.lib shcore.lib)
 
 # Set the correct working directory
 set_property(TARGET Samples PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PHYSICS_REPO_ROOT}")

+ 0 - 4
Samples/pch.cpp

@@ -1,4 +0,0 @@
-// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
-// SPDX-License-Identifier: MIT
-
-#include <TestFramework.h>

+ 2 - 8
TestFramework/TestFramework.cmake

@@ -81,13 +81,6 @@ set(TEST_FRAMEWORK_SRC_FILES
 	${TEST_FRAMEWORK_ROOT}/Utils/ReadData.h
 )
 
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
-	# Enable Precompiled Headers for TestFramework
-	set_source_files_properties(${TEST_FRAMEWORK_SRC_FILES} PROPERTIES COMPILE_FLAGS "/YuTestFramework.h")
-	set(TEST_FRAMEWORK_SRC_FILES ${TEST_FRAMEWORK_SRC_FILES} ${TEST_FRAMEWORK_ROOT}/pch.cpp)
-	set_source_files_properties(${TEST_FRAMEWORK_ROOT}/pch.cpp PROPERTIES COMPILE_FLAGS "/YcTestFramework.h")
-endif()
-
 # Group source files
 source_group(TREE ${TEST_FRAMEWORK_ROOT} FILES ${TEST_FRAMEWORK_SRC_FILES})
 
@@ -125,4 +118,5 @@ source_group(TREE ${PHYSICS_REPO_ROOT} FILES ${TEST_FRAMEWORK_SRC_FILES_SHADERS}
 # Create TestFramework lib
 add_library(TestFramework STATIC ${TEST_FRAMEWORK_SRC_FILES} ${TEST_FRAMEWORK_SRC_FILES_SHADERS})
 target_include_directories(TestFramework PUBLIC ${TEST_FRAMEWORK_ROOT})
-target_link_libraries (TestFramework LINK_PUBLIC Jolt)
+target_link_libraries(TestFramework LINK_PUBLIC Jolt)
+target_precompile_headers(TestFramework PUBLIC ${TEST_FRAMEWORK_ROOT}/TestFramework.h)

+ 0 - 1
TestFramework/pch.cpp

@@ -1 +0,0 @@
-#include <TestFramework.h>