diff --git a/CMakeLists.txt b/CMakeLists.txt index 42161c6d2..2e21ee8e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -333,19 +333,20 @@ ENDIF() INCLUDE (FindPkgMacros) INCLUDE (PrecompiledHeader) -# If this is an in-source build (CMAKE_SOURCE_DIR == CMAKE_BINARY_DIR), -# write the library/executable files to the respective directories in the -# source tree. During an out-of-source build, however, do not litter this -# directory, since that is probably what the user wanted to avoid. -IF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) - SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin" ) - SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib" ) - SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/bin" ) -ELSE() - SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") - SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") - SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") -ENDIF () +# Set Assimp project output directory variables. +SET(ASSIMP_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") +SET(ASSIMP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") +SET(ASSIMP_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") + +# Macro used to set the output directories of a target to the +# respective Assimp output directories. +MACRO(TARGET_USE_COMMON_OUTPUT_DIRECTORY target) + set_target_properties(${target} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${ASSIMP_RUNTIME_OUTPUT_DIRECTORY} + LIBRARY_OUTPUT_DIRECTORY ${ASSIMP_LIBRARY_OUTPUT_DIRECTORY} + ARCHIVE_OUTPUT_DIRECTORY ${ASSIMP_ARCHIVE_OUTPUT_DIRECTORY} + ) +ENDMACRO() get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 7ccc6439f..9fafa4944 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1136,6 +1136,8 @@ ENDIF () ADD_LIBRARY( assimp ${assimp_src} ) ADD_LIBRARY(assimp::assimp ALIAS assimp) +TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp) + # enable warnings as errors ######################################## IF (MSVC) TARGET_COMPILE_OPTIONS(assimp PRIVATE /WX) diff --git a/samples/SimpleOpenGL/CMakeLists.txt b/samples/SimpleOpenGL/CMakeLists.txt index 6bc8e37e6..ba5deb4cf 100644 --- a/samples/SimpleOpenGL/CMakeLists.txt +++ b/samples/SimpleOpenGL/CMakeLists.txt @@ -44,6 +44,8 @@ ADD_EXECUTABLE( ${SAMPLE_PROJECT_NAME} Sample_SimpleOpenGL.c ) +TARGET_USE_COMMON_OUTPUT_DIRECTORY(${SAMPLE_PROJECT_NAME}) + SET_PROPERTY(TARGET ${SAMPLE_PROJECT_NAME} PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) TARGET_LINK_LIBRARIES( ${SAMPLE_PROJECT_NAME} assimp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${M_LIB} ) diff --git a/samples/SimpleTexturedDirectx11/CMakeLists.txt b/samples/SimpleTexturedDirectx11/CMakeLists.txt index 9eec738f5..82144caa9 100644 --- a/samples/SimpleTexturedDirectx11/CMakeLists.txt +++ b/samples/SimpleTexturedDirectx11/CMakeLists.txt @@ -37,6 +37,8 @@ ADD_EXECUTABLE( assimp_simpletextureddirectx11 WIN32 ${SAMPLES_SHARED_CODE_DIR}/UTFConverter.h ) +TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp_simpletextureddirectx11) + SET_PROPERTY(TARGET assimp_simpletextureddirectx11 PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) TARGET_LINK_LIBRARIES( assimp_simpletextureddirectx11 assimp comctl32.lib winmm.lib ) diff --git a/samples/SimpleTexturedOpenGL/CMakeLists.txt b/samples/SimpleTexturedOpenGL/CMakeLists.txt index 83cd2746e..1837af033 100644 --- a/samples/SimpleTexturedOpenGL/CMakeLists.txt +++ b/samples/SimpleTexturedOpenGL/CMakeLists.txt @@ -34,6 +34,8 @@ ADD_EXECUTABLE( assimp_simpletexturedogl WIN32 ${SAMPLES_SHARED_CODE_DIR}/UTFConverter.h ) +TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp_simpletexturedogl) + SET_PROPERTY(TARGET assimp_simpletexturedogl PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) TARGET_LINK_LIBRARIES( assimp_simpletexturedogl assimp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8e1746ce2..ff4d51d78 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -208,6 +208,8 @@ add_executable( unit ${POST_PROCESSES} ) +TARGET_USE_COMMON_OUTPUT_DIRECTORY(unit) + add_definitions(-DASSIMP_TEST_MODELS_DIR="${CMAKE_CURRENT_LIST_DIR}/models") add_definitions(-DASSIMP_TEST_MODELS_NONBSD_DIR="${CMAKE_CURRENT_LIST_DIR}/models-nonbsd") diff --git a/tools/assimp_cmd/CMakeLists.txt b/tools/assimp_cmd/CMakeLists.txt index d46d09c2b..a0eb98a89 100644 --- a/tools/assimp_cmd/CMakeLists.txt +++ b/tools/assimp_cmd/CMakeLists.txt @@ -59,6 +59,8 @@ ADD_EXECUTABLE( assimp_cmd Export.cpp ) +TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp_cmd) + SET_PROPERTY(TARGET assimp_cmd PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) TARGET_LINK_LIBRARIES( assimp_cmd assimp ${ZLIB_LIBRARIES} ) diff --git a/tools/assimp_view/CMakeLists.txt b/tools/assimp_view/CMakeLists.txt index 2785bd882..222722388 100644 --- a/tools/assimp_view/CMakeLists.txt +++ b/tools/assimp_view/CMakeLists.txt @@ -86,6 +86,8 @@ ADD_EXECUTABLE( assimp_viewer WIN32 txi.bmp ) +TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp_viewer) + SET_PROPERTY(TARGET assimp_viewer PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) IF ( MSVC )