From ec68dac3a168d2e4a23da707bd930e0c968422fc Mon Sep 17 00:00:00 2001 From: Luc Touraille Date: Thu, 18 Apr 2024 16:54:16 +0200 Subject: [PATCH] build: Don't change CMAKE_XXX_OUTPUT_DIRECTORY when built as subdir When building OIIO as a subdirectory of a super-project (with `add_subdirectory`), it is better to honor the output directories specified by the parent project. In our project, it was causing issues because OIIO libs were ending in a different folder from USD plugins, which thereby failed to load correctly in the build tree. Signed-off-by: Luc Touraille --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf39062d4c..b1bc990624 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,9 +87,11 @@ message (STATUS "Build type = ${CMAKE_BUILD_TYPE}") message (STATUS "Supported release = ${${PROJECT_NAME}_SUPPORTED_RELEASE}") # Make the build area layout look a bit more like the final dist layout -set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +if (PROJECT_IS_TOP_LEVEL) + set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +endif() if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") message (FATAL_ERROR "Not allowed to run in-source build!")