设定cmake输出目录
对于我来说,我使用的是cmake 3.5,但below(set variable)不起作用:
set(
ARCHIVE_OUTPUT_DIRECTORY "/home/xy/cmake_practice/lib/"
LIBRARY_OUTPUT_DIRECTORY "/home/xy/cmake_practice/lib/"
RUNTIME_OUTPUT_DIRECTORY "/home/xy/cmake_practice/bin/"
)
但这有效(set set_target_properties):
set_target_properties(demo5
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "/home/xy/cmake_practice/lib/"
LIBRARY_OUTPUT_DIRECTORY "/home/xy/cmake_practice/lib/"
RUNTIME_OUTPUT_DIRECTORY "/home/xy/cmake_practice/bin/"
)
这个函数也没起作用
FUNCTION(SET_OUTPUT_DIR customDir)
MESSAGE("${customDir}")
SET (OUTPUT_DIR "${customDir}")
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${OUTPUT_DIR}")
foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
STRING (TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${OUTPUT_DIR}")
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${OUTPUT_DIR}")
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${OUTPUT_DIR}")
endforeach ()
MESSAGE (STATUS "Output path: ${OUTPUT_DIR}")
ENDFUNCTION()