Browse Source

Workaround for Ninja Multi-Config erroring out (#1212)

Fixes #1211
Jorrit Rouwe 1 year ago
parent
commit
b53b830ca8
2 changed files with 19 additions and 2 deletions
  1. 12 1
      Build/CMakeLists.txt
  2. 7 1
      Jolt/Jolt.cmake

+ 12 - 1
Build/CMakeLists.txt

@@ -314,15 +314,26 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
 		add_executable(UnitTests ${UNIT_TESTS_SRC_FILES})
 		target_include_directories(UnitTests PUBLIC ${UNIT_TESTS_ROOT})
 		target_link_libraries(UnitTests LINK_PUBLIC Jolt)
-		target_precompile_headers(UnitTests PRIVATE "$<$<NOT:$<CONFIG:ReleaseCoverage>>:${JOLT_PHYSICS_ROOT}/Jolt.h>") # Code coverage doesn't work when using precompiled headers
+
+		# Code coverage doesn't work when using precompiled headers
+		if (CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND MSVC)
+			# The Ninja Multi-Config generator errors out when selectively disabling precompiled headers for certain configurations.
+			# See: https://github.com/jrouwe/JoltPhysics/issues/1211
+			target_precompile_headers(UnitTests PRIVATE "${JOLT_PHYSICS_ROOT}/Jolt.h")
+		else()
+			target_precompile_headers(UnitTests PRIVATE "$<$<NOT:$<CONFIG:ReleaseCoverage>>:${JOLT_PHYSICS_ROOT}/Jolt.h>")
+		endif()
+
 		if (MSVC)
 			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")
 		endif()
+
 		if (XCODE)
 			# Ensure that we enable SSE4.2 for the x86_64 build, XCode builds multiple architectures
 			set_property(TARGET UnitTests PROPERTY XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=x86_64] "$(inherited) -msse4.2 -mpopcnt")

+ 7 - 1
Jolt/Jolt.cmake

@@ -501,7 +501,13 @@ target_include_directories(Jolt PUBLIC
 	$<INSTALL_INTERFACE:include/>)
 
 # Code coverage doesn't work when using precompiled headers
-target_precompile_headers(Jolt PRIVATE "$<$<NOT:$<CONFIG:ReleaseCoverage>>:${JOLT_PHYSICS_ROOT}/Jolt.h>")
+if (CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND MSVC)
+	# The Ninja Multi-Config generator errors out when selectively disabling precompiled headers for certain configurations.
+	# See: https://github.com/jrouwe/JoltPhysics/issues/1211
+	target_precompile_headers(Jolt PRIVATE "${JOLT_PHYSICS_ROOT}/Jolt.h")
+else()
+	target_precompile_headers(Jolt PRIVATE "$<$<NOT:$<CONFIG:ReleaseCoverage>>:${JOLT_PHYSICS_ROOT}/Jolt.h>")
+endif()
 
 if (NOT CPP_EXCEPTIONS_ENABLED)
 	# Disable use of exceptions in MSVC's STL