From 7f2ab47b5a3c8de15cad7533cece3846de819015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on?= Date: Tue, 11 Jan 2022 18:36:05 +0100 Subject: [PATCH 1/2] Respect top-level CMAKE_*_OUTPUT_DIRECTORY variables --- CMakeLists.txt | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd12d3a9d..15970a487 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,9 +341,24 @@ INCLUDE (FindPkgMacros) INCLUDE (PrecompiledHeader) # Set Assimp project output directory variables. -SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for runtime output files") -SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for library output files") -SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib" CACHE STRING "Path for archive output files") +# Will respect top-level CMAKE_*_OUTPUT_DIRECTORY variables if any are set. +IF(CMAKE_RUNTIME_OUTPUT_DIRECTORY STREQUAL "") + SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for runtime output files") +ELSE() + SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} CACHE STRING "Path for runtime output files") +ENDIF() + +IF(CMAKE_LIBRARY_OUTPUT_DIRECTORY STREQUAL "") + SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for library output files") +ELSE() + SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} CACHE STRING "Path for runtime output files") +ENDIF() + +IF(CMAKE_ARCHIVE_OUTPUT_DIRECTORY STREQUAL "") + SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib" CACHE STRING "Path for library output files") +ELSE() + SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} CACHE STRING "Path for runtime output files") +ENDIF() # Macro used to set the output directories of a target to the # respective Assimp output directories. From 8a7576b85c8eb6722d134047f76c3949bca48d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on?= Date: Wed, 12 Jan 2022 15:04:41 +0100 Subject: [PATCH 2/2] Check for variable definition rather than empty string --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15970a487..d0ec4cea9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,19 +342,19 @@ INCLUDE (PrecompiledHeader) # Set Assimp project output directory variables. # Will respect top-level CMAKE_*_OUTPUT_DIRECTORY variables if any are set. -IF(CMAKE_RUNTIME_OUTPUT_DIRECTORY STREQUAL "") +IF(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for runtime output files") ELSE() SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} CACHE STRING "Path for runtime output files") ENDIF() -IF(CMAKE_LIBRARY_OUTPUT_DIRECTORY STREQUAL "") +IF(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" CACHE STRING "Path for library output files") ELSE() SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} CACHE STRING "Path for runtime output files") ENDIF() -IF(CMAKE_ARCHIVE_OUTPUT_DIRECTORY STREQUAL "") +IF(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY) SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib" CACHE STRING "Path for library output files") ELSE() SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} CACHE STRING "Path for runtime output files")