对Lib项目的统一输出路径以下时解决方案:
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Bin)
以上三行命令要写在根(root)CmakeLists.txt的里面.
Reference:
http://*.com/questions/3702115/creating-a-directory-in-cmake
http://*.com/questions/3742090/custom-directory-for-cmake-library-output
http://*.com/questions/17653738/recursive-cmake-search-for-header-and-source-files
http://*.com/questions/6594796/how-do-i-make-cmake-output-into-a-bin-dir
项目依赖的头文件的输出路径:
References:
http://*.com/questions/5668397/cmake-export-third-party-headers-to-directory
http://*.com/questions/697560/how-to-copy-directory-from-source-tree-to-binary-tree
以下是(root)CmakeLists.txt的代码:
cmake_minimum_required(VERSION 2.8) #set(CMAKE_C_COMPILER "D:\VS2008Release\VC\bin\amd64")
#set(CMAKE_CXX_COMPILER "D:\VS2008Release\VC\bin\amd64") PROJECT(ImageMagick) #set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Lib)
#set(ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Lib")
#message(STATUS ${CMAKE_BINARY_DIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Bin) #set(SHARE_LIBS_DIR ${CMAKE_BINARY_DIR}/Lib) add_subdirectory(bzlib)
add_subdirectory(cairo)
add_subdirectory(coders)
add_subdirectory(croco)
add_subdirectory(ffi)
add_subdirectory(filters)
add_subdirectory(glib)
add_subdirectory(jbig)
add_subdirectory(jp2)
add_subdirectory(jpeg)
add_subdirectory(lcms)
add_subdirectory(librsvg)
add_subdirectory(libxml)
add_subdirectory(lqr)
add_subdirectory(magick)
add_subdirectory(Magick++)
add_subdirectory(pango)
add_subdirectory(pixman)
add_subdirectory(png)
add_subdirectory(tiff)
add_subdirectory(ttf)
add_subdirectory(wand)
add_subdirectory(webp)
add_subdirectory(wmf)
add_subdirectory(zlib) #头文件输出
file(COPY "${CMAKE_BINARY_DIR}/Magick++/lib/Magick++.h"
DESTINATION "${CMAKE_BINARY_DIR}/include" ) #wand文件夹 file(GLOB wand_hdrs "${CMAKE_BINARY_DIR}/wand/*.h")
file(COPY ${wand_hdrs}
DESTINATION "${CMAKE_BINARY_DIR}/include/wand" ) file(COPY "${CMAKE_BINARY_DIR}/VisualMagick/wand/wand-config.h.in"
DESTINATION "${CMAKE_BINARY_DIR}/include/wand" )
#文件重命名
file(RENAME "${CMAKE_BINARY_DIR}/include/wand/wand-config.h.in" "${CMAKE_BINARY_DIR}/include/wand/wand-config.h") #Magick++文件夹
file(GLOB Magick_hdrs "${CMAKE_BINARY_DIR}/Magick++/lib/Magick++/*.h")
file(COPY ${Magick_hdrs}
DESTINATION "${CMAKE_BINARY_DIR}/include/Magick++" ) #magick文件夹
file(GLOB magick_hdrs "${CMAKE_BINARY_DIR}/magick/*.h")
file(COPY ${magick_hdrs}
DESTINATION "${CMAKE_BINARY_DIR}/include/magick"
) #wand
#add_subdirectory(cairo)
TIPS:add_subdirectory命令执行中,就直接执行子目录下的CmakeLists.txt里面的代码了