Browse Source

CMake: Add convenience variable for generator expression-based intdir

In some situations is better to use a generator expression over $(CONFIGURATION), so add a convenience variable so I don't have to keep duplicating checks all over the place.
Donny Lawrence 6 years ago
parent
commit
14f2e48654

+ 8 - 1
CMakeLists.txt

@@ -23,7 +23,14 @@ unset(_version)
 
 
 enable_testing()
 enable_testing()
 
 
+# Create some convenience variables for the build configuration intdir. One uses
+# the build system's representation, while the other uses a generator expression.
 string(REPLACE "$(EFFECTIVE_PLATFORM_NAME)" "" PANDA_CFG_INTDIR "${CMAKE_CFG_INTDIR}")
 string(REPLACE "$(EFFECTIVE_PLATFORM_NAME)" "" PANDA_CFG_INTDIR "${CMAKE_CFG_INTDIR}")
+if(PANDA_CFG_INTDIR STREQUAL ".")
+  set(PANDA_CFG_INTDIR_GEN ".")
+else()
+  set(PANDA_CFG_INTDIR_GEN "$<CONFIG>")
+endif()
 
 
 # Add generic modules to cmake module path,
 # Add generic modules to cmake module path,
 # and add Panda3D specific modules to cmake module path
 # and add Panda3D specific modules to cmake module path
@@ -109,7 +116,7 @@ if(BUILD_MODELS)
                              -P ${PROJECT_SOURCE_DIR}/cmake/scripts/CopyPattern.cmake
                              -P ${PROJECT_SOURCE_DIR}/cmake/scripts/CopyPattern.cmake
                      COMMENT "Copying dmodels' assets")
                      COMMENT "Copying dmodels' assets")
 
 
-  install(DIRECTORY "${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR}/models"
+  install(DIRECTORY "${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR_GEN}/models"
     COMPONENT Models DESTINATION share/panda3d)
     COMPONENT Models DESTINATION share/panda3d)
 endif()
 endif()
 
 

+ 1 - 8
cmake/macros/Python.cmake

@@ -51,14 +51,7 @@ function(add_python_target target)
   target_link_libraries(${target} PKG::PYTHON)
   target_link_libraries(${target} PKG::PYTHON)
 
 
   if(BUILD_SHARED_LIBS)
   if(BUILD_SHARED_LIBS)
-    if(CMAKE_GENERATOR STREQUAL "Xcode")
-      # This is explained in CompilerFlags.cmake
-      set(intdir $<CONFIG>)
-    else()
-      set(intdir ${PANDA_CFG_INTDIR})
-    endif()
-
-    set(_outdir "${PROJECT_BINARY_DIR}/${intdir}/${slash_namespace}")
+    set(_outdir "${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR_GEN}/${slash_namespace}")
 
 
     set_target_properties(${target} PROPERTIES
     set_target_properties(${target} PROPERTIES
       LIBRARY_OUTPUT_DIRECTORY "${_outdir}"
       LIBRARY_OUTPUT_DIRECTORY "${_outdir}"

+ 3 - 9
dtool/CompilerFlags.cmake

@@ -37,17 +37,11 @@ if(CMAKE_GENERATOR STREQUAL "Xcode")
 
 
   # Xcode complains about codesigning if this option isn't set.
   # Xcode complains about codesigning if this option isn't set.
   set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
   set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
-
-  # On the Xcode generator, CMake generates a separate make target definition for
-  # every config, so it ends up spamming warnings once we try to build.
-  set(intdir $<CONFIG>)
-else()
-  set(intdir ${PANDA_CFG_INTDIR})
 endif()
 endif()
 
 
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${intdir}/bin")
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${intdir}/lib")
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${intdir}/lib")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR_GEN}/bin")
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR_GEN}/lib")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR_GEN}/lib")
 
 
 set(MODULE_DESTINATION "lib")
 set(MODULE_DESTINATION "lib")
 
 

+ 1 - 9
dtool/LocalSetup.cmake

@@ -195,14 +195,6 @@ message("See dtool_config.h for more details about the specified configuration."
 message("")
 message("")
 
 
 # Generate dtool_config.h
 # Generate dtool_config.h
-if("${PANDA_CFG_INTDIR}" STREQUAL ".")
-  # Single-configuration generator
-  set(intdir ".")
-else()
-  # Multi-configuration generator
-  set(intdir "${CMAKE_BUILD_TYPE}")
-endif()
-
 if(IS_MULTICONFIG)
 if(IS_MULTICONFIG)
   foreach(config ${CMAKE_CONFIGURATION_TYPES})
   foreach(config ${CMAKE_CONFIGURATION_TYPES})
     foreach(option ${PER_CONFIG_OPTIONS})
     foreach(option ${PER_CONFIG_OPTIONS})
@@ -227,7 +219,7 @@ else()
   configure_file(dtool_config.h.in "${PROJECT_BINARY_DIR}/include/dtool_config.h")
   configure_file(dtool_config.h.in "${PROJECT_BINARY_DIR}/include/dtool_config.h")
 endif()
 endif()
 
 
-install(FILES "${PROJECT_BINARY_DIR}/${intdir}/include/dtool_config.h"
+install(FILES "${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR_GEN}/include/dtool_config.h"
   COMPONENT CoreDevel
   COMPONENT CoreDevel
   DESTINATION include/panda3d)
   DESTINATION include/panda3d)
 
 

+ 1 - 1
panda/src/configfiles/CMakeLists.txt

@@ -37,4 +37,4 @@ if(IS_MULTICONFIG)
                 INPUT "${PROJECT_BINARY_DIR}/etc/20_panda.prc")
                 INPUT "${PROJECT_BINARY_DIR}/etc/20_panda.prc")
 endif()
 endif()
 
 
-install(FILES "${CMAKE_BINARY_DIR}/etc/20_panda.prc" COMPONENT Core DESTINATION etc)
+install(FILES "${CMAKE_BINARY_DIR}/${PANDA_CFG_INTDIR_GEN}/etc/20_panda.prc" COMPONENT Core DESTINATION etc)