Skip to content

Commit 33a772d

Browse files
build: Don't change CMAKE_XXX_OUTPUT_DIRECTORY when built as subdir (AcademySoftwareFoundation#4417)
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 <[email protected]>
1 parent 1ba3d45 commit 33a772d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ message (STATUS "Build type = ${CMAKE_BUILD_TYPE}")
8787
message (STATUS "Supported release = ${${PROJECT_NAME}_SUPPORTED_RELEASE}")
8888

8989
# Make the build area layout look a bit more like the final dist layout
90-
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
91-
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
92-
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
90+
if (PROJECT_IS_TOP_LEVEL)
91+
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
92+
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
93+
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
94+
endif()
9395

9496
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
9597
message (FATAL_ERROR "Not allowed to run in-source build!")

0 commit comments

Comments
 (0)