From f5b910326d925db69dd67e5c9fea60a1972d514e Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 14 Jun 2016 18:28:00 -0400 Subject: [PATCH] Improve binary distribution CMake macros (issue #1923) --- cmake/cef_macros.cmake.in | 18 +++++++++++------- tests/cefclient/CMakeLists.txt.in | 2 +- tests/cefsimple/CMakeLists.txt.in | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cmake/cef_macros.cmake.in b/cmake/cef_macros.cmake.in index 0f3b9ca64..12cd79229 100644 --- a/cmake/cef_macros.cmake.in +++ b/cmake/cef_macros.cmake.in @@ -81,11 +81,15 @@ endmacro() # Determine the target output directory based on platform and generator. macro(SET_CEF_TARGET_OUT_DIR) - if(${CMAKE_GENERATOR} STREQUAL "Ninja") - # Ninja does not create a subdirectory named after the configuration. - set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") - elseif(OS_LINUX) + if(${CMAKE_GENERATOR} STREQUAL "Ninja" OR + ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles") + # By default Ninja and Make builds don't create a subdirectory named after + # the configuration. set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}") + + # Output binaries (executables, libraries) to the correct directory. + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR}) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR}) else() set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/$") endif() @@ -256,13 +260,13 @@ endif(OS_MACOSX) if(OS_WINDOWS) # Add custom manifest files to an executable target. -macro(ADD_WINDOWS_MANIFEST manifest_path target) +macro(ADD_WINDOWS_MANIFEST manifest_path target extension) add_custom_command( TARGET ${target} POST_BUILD COMMAND "mt.exe" -nologo - -manifest \"${manifest_path}/${target}.exe.manifest\" \"${manifest_path}/compatibility.manifest\" - -outputresource:"${CEF_TARGET_OUT_DIR}/${target}.exe"\;\#1 + -manifest \"${manifest_path}/${target}.${extension}.manifest\" \"${manifest_path}/compatibility.manifest\" + -outputresource:"${CEF_TARGET_OUT_DIR}/${target}.${extension}"\;\#1 COMMENT "Adding manifest..." ) endmacro() diff --git a/tests/cefclient/CMakeLists.txt.in b/tests/cefclient/CMakeLists.txt.in index 6e4731259..d45c4ad00 100644 --- a/tests/cefclient/CMakeLists.txt.in +++ b/tests/cefclient/CMakeLists.txt.in @@ -246,7 +246,7 @@ if(OS_WINDOWS) endif() # Add the custom manifest files to the executable. - ADD_WINDOWS_MANIFEST("${CMAKE_CURRENT_SOURCE_DIR}/resources/win" "${CEF_TARGET}") + ADD_WINDOWS_MANIFEST("${CMAKE_CURRENT_SOURCE_DIR}/resources/win" "${CEF_TARGET}" "exe") # Copy CEF binary and resource files to the target output directory. COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}") diff --git a/tests/cefsimple/CMakeLists.txt.in b/tests/cefsimple/CMakeLists.txt.in index 14a4a762e..faf8d4677 100644 --- a/tests/cefsimple/CMakeLists.txt.in +++ b/tests/cefsimple/CMakeLists.txt.in @@ -157,7 +157,7 @@ if(OS_WINDOWS) endif() # Add the custom manifest files to the executable. - ADD_WINDOWS_MANIFEST("${CMAKE_CURRENT_SOURCE_DIR}" "${CEF_TARGET}") + ADD_WINDOWS_MANIFEST("${CMAKE_CURRENT_SOURCE_DIR}" "${CEF_TARGET}" "exe") # Copy binary and resource files to the target output directory. COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")