From be4fe131d5fee47c6e407e76f46b12edf29edba9 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Sat, 15 Feb 2020 13:10:11 -0500 Subject: [PATCH] Made changes to write compiled binaries to a common directory. The following changes were tested with the following projects: - assimp DLL - unit tests - tools/assimp_cmd - tools/assimp viewer - samples/SimpleOpenGL - samples/SimpleTexturedDirectx11 - samples/SimpleTexturedOpenGL For each program listed above, the results were tested when (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) is true and false. Also, the "lib" in SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib") was changed to "bin" to allow DLLs to be written to executables/launchables programs directory. --- CMakeLists.txt | 6 +++++- test/CMakeLists.txt | 7 ------- tools/assimp_cmd/CMakeLists.txt | 7 ------- tools/assimp_view/CMakeLists.txt | 7 ------- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38ebf3480..08a1f3010 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,9 +342,13 @@ INCLUDE (PrecompiledHeader) # 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}/lib" ) + 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 ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) # Cache these to allow the user to override them manually. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8624a065f..b1d918a86 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -205,13 +205,6 @@ ELSE( WIN32 ) SET( platform_libs pthread ) ENDIF( WIN32 ) -IF( WIN32 ) - ADD_CUSTOM_COMMAND(TARGET unit - PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ - MAIN_DEPENDENCY assimp) -ENDIF( WIN32 ) - IF(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) ENDIF(MSVC) diff --git a/tools/assimp_cmd/CMakeLists.txt b/tools/assimp_cmd/CMakeLists.txt index fcf36c356..848b8f81c 100644 --- a/tools/assimp_cmd/CMakeLists.txt +++ b/tools/assimp_cmd/CMakeLists.txt @@ -61,13 +61,6 @@ ADD_EXECUTABLE( assimp_cmd SET_PROPERTY(TARGET assimp_cmd PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) -IF( WIN32 ) - ADD_CUSTOM_COMMAND(TARGET assimp_cmd - PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ - MAIN_DEPENDENCY assimp) -ENDIF( WIN32 ) - TARGET_LINK_LIBRARIES( assimp_cmd assimp ${ZLIB_LIBRARIES} ) SET_TARGET_PROPERTIES( assimp_cmd PROPERTIES OUTPUT_NAME assimp diff --git a/tools/assimp_view/CMakeLists.txt b/tools/assimp_view/CMakeLists.txt index 001444e0e..dc1cee0d2 100644 --- a/tools/assimp_view/CMakeLists.txt +++ b/tools/assimp_view/CMakeLists.txt @@ -92,13 +92,6 @@ IF ( MSVC ) REMOVE_DEFINITIONS( -DUNICODE -D_UNICODE ) ENDIF ( MSVC ) - -# -ADD_CUSTOM_COMMAND(TARGET assimp_viewer - PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ - MAIN_DEPENDENCY assimp) - # Link the executable to the assimp + dx libs. TARGET_LINK_LIBRARIES ( assimp_viewer assimp ${DirectX_LIBRARY} ${DirectX_D3DX9_LIBRARY} comctl32.lib winmm.lib )