diff --git a/CMakeLists.txt b/CMakeLists.txt index fdc0008c1c..402f0e4c5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,19 +91,19 @@ if(BUILD_MODELS) POST_BUILD COMMAND ${CMAKE_COMMAND} -DSOURCE="${CMAKE_CURRENT_SOURCE_DIR}/models/maps/" - -DDESTINATION="${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR}/models/maps" + -DDESTINATION="${PANDA_OUTPUT_DIR}/models/maps" -P ${PROJECT_SOURCE_DIR}/cmake/scripts/CopyPattern.cmake COMMENT "Copying models/maps") add_custom_command(TARGET dmodels POST_BUILD COMMAND ${CMAKE_COMMAND} -DSOURCE="${CMAKE_CURRENT_SOURCE_DIR}/dmodels/src/" - -DDESTINATION="${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR}/models" + -DDESTINATION="${PANDA_OUTPUT_DIR}/models" -DFILES_MATCHING="PATTERN;*.rgb;PATTERN;*.png;PATTERN;*.jpg;PATTERN;*.wav" -P ${PROJECT_SOURCE_DIR}/cmake/scripts/CopyPattern.cmake COMMENT "Copying dmodels' assets") - install(DIRECTORY "${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR}/models" + install(DIRECTORY "${PANDA_OUTPUT_DIR}/models" COMPONENT Models DESTINATION share/panda3d) endif() @@ -112,15 +112,9 @@ if(INTERROGATE_PYTHON_INTERFACE) # for pytest before adding this test. If the user doesn't have pytest, we'd # like for the tests to fail. - if(PANDA_CFG_INTDIR STREQUAL ".") - set(_workdir "${PROJECT_BINARY_DIR}") - else() - set(_workdir "${PROJECT_BINARY_DIR}/$") - endif() - add_test(NAME pytest COMMAND "${PYTHON_EXECUTABLE}" -m pytest "${PROJECT_SOURCE_DIR}/tests" - WORKING_DIRECTORY "${_workdir}") + WORKING_DIRECTORY "${PANDA_OUTPUT_DIR}") endif() # Generate the Panda3DConfig.cmake file so find_package(Panda3D) works, and diff --git a/cmake/macros/Python.cmake b/cmake/macros/Python.cmake index 9c01024e01..e247052214 100644 --- a/cmake/macros/Python.cmake +++ b/cmake/macros/Python.cmake @@ -51,14 +51,7 @@ function(add_python_target target) target_link_libraries(${target} PKG::PYTHON) if(BUILD_SHARED_LIBS) - if(CMAKE_GENERATOR STREQUAL "Xcode") - # This is explained in CompilerFlags.cmake - set(intdir $) - else() - set(intdir ${PANDA_CFG_INTDIR}) - endif() - - set(_outdir "${PROJECT_BINARY_DIR}/${intdir}/${slash_namespace}") + set(_outdir "${PANDA_OUTPUT_DIR}/${slash_namespace}") set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${_outdir}" @@ -146,7 +139,7 @@ function(install_python_package package_name) set(src_path "${CMAKE_SOURCE_DIR}/cmake/templates/win32_python") endif() - set(path "${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR}/${package_name}") + set(path "${PANDA_OUTPUT_DIR}/${package_name}") set(args -D "OUTPUT_DIR=${path}") if(src_path) diff --git a/dtool/CompilerFlags.cmake b/dtool/CompilerFlags.cmake index 5192d57946..2e4194ff9b 100644 --- a/dtool/CompilerFlags.cmake +++ b/dtool/CompilerFlags.cmake @@ -30,17 +30,19 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Set up the output directory structure, mimicking that of makepanda set(CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}/cmake") -if(CMAKE_GENERATOR STREQUAL "Xcode") - # 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 $) +if(CMAKE_CFG_INTDIR STREQUAL ".") + # Single-configuration generator; output goes straight in the binary dir + set(PANDA_OUTPUT_DIR "${PROJECT_BINARY_DIR}") + else() - set(intdir ${PANDA_CFG_INTDIR}) + # Multi-configuration generator; add a per-configuration path prefix + set(PANDA_OUTPUT_DIR "${PROJECT_BINARY_DIR}/$") + 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 "${PANDA_OUTPUT_DIR}/bin") +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PANDA_OUTPUT_DIR}/lib") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PANDA_OUTPUT_DIR}/lib") set(MODULE_DESTINATION "lib") @@ -54,7 +56,7 @@ if(WIN32) set(CMAKE_STATIC_LIBRARY_PREFIX "lib") # On Windows, modules (DLLs) are located in bin; lib is just for .lib files - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${PANDA_CFG_INTDIR}/bin") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PANDA_OUTPUT_DIR}/bin") if(BUILD_SHARED_LIBS) set(MODULE_DESTINATION "bin") endif() @@ -66,22 +68,20 @@ if(APPLE) set(CMAKE_SHARED_MODULE_SUFFIX ".dylib") endif() -# Since we're using CMAKE_CFG_INTDIR to put everything in a -# configuration-specific subdirectory when building on a multi-config -# generator, we need to suppress the usual configuration name appending -# behavior of CMake. In CMake 3.4+, it will suppress this behavior +# We want the output structured like build/CONFIG/bin, not build/bin/CONFIG per +# the default for multi-configuration generators. In CMake 3.4+, it switches # automatically if the *_OUTPUT_DIRECTORY property contains a generator -# expresssion, but: -# a) As of this writing we support as early as CMake 3.0.2 -# b) ${CMAKE_CFG_INTDIR} doesn't actually expand to a generator expression +# expresssion, but as of this writing we support as early as CMake 3.0.2. # -# So, to solve both of these, let's just do this: -foreach(_type RUNTIME ARCHIVE LIBRARY) - foreach(_config ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER "${_config}" _config) - set(CMAKE_${_type}_OUTPUT_DIRECTORY_${_config} "${CMAKE_${_type}_OUTPUT_DIRECTORY}") - endforeach(_config) -endforeach(_type) +# So, let's just do this: +if(CMAKE_VERSION VERSION_LESS "3.4") + foreach(_type RUNTIME ARCHIVE LIBRARY) + foreach(_config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${_config}" _config) + set(CMAKE_${_type}_OUTPUT_DIRECTORY_${_config} "${CMAKE_${_type}_OUTPUT_DIRECTORY}") + endforeach(_config) + endforeach(_type) +endif() # Set warning levels if(MSVC) diff --git a/dtool/LocalSetup.cmake b/dtool/LocalSetup.cmake index 70cf8d6683..a6fc3a0147 100644 --- a/dtool/LocalSetup.cmake +++ b/dtool/LocalSetup.cmake @@ -185,14 +185,6 @@ message("See dtool_config.h for more details about the specified configuration." message("") # 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) foreach(config ${CMAKE_CONFIGURATION_TYPES}) foreach(option ${PER_CONFIG_OPTIONS}) @@ -217,7 +209,7 @@ else() configure_file(dtool_config.h.in "${PROJECT_BINARY_DIR}/include/dtool_config.h") endif() -install(FILES "${PROJECT_BINARY_DIR}/${intdir}/include/dtool_config.h" +install(FILES "${PANDA_OUTPUT_DIR}/include/dtool_config.h" COMPONENT CoreDevel DESTINATION include/panda3d) diff --git a/dtool/src/dtoolbase/CMakeLists.txt b/dtool/src/dtoolbase/CMakeLists.txt index e2bfc81b90..b6a8de0952 100644 --- a/dtool/src/dtoolbase/CMakeLists.txt +++ b/dtool/src/dtoolbase/CMakeLists.txt @@ -91,7 +91,7 @@ add_component_library(p3dtoolbase NOINIT SYMBOL BUILDING_DTOOL_DTOOLBASE # Help other libraries find the autogenerated headers target_include_directories(p3dtoolbase PUBLIC $ - $) + $) target_link_libraries(p3dtoolbase PKG::EIGEN PKG::THREADS) target_interrogate(p3dtoolbase ${P3DTOOLBASE_SOURCES} EXTENSIONS ${P3DTOOLBASE_IGATEEXT})