我有一堆我必须构建的库。对于每个库,我创建了3个sym-links。 我使用:
创建了两个符号链接add_library(${PROJECT_NAME} ${SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${perception_kit_VERSION})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${Boost_LIBS})
但剩下的两个是使用:
创建的#code for generating symlink. will work with make install
if (CMAKE_HOST_UNIX)
set (libname_major_minor_patch "lib${PROJECT_NAME}.so.${perception_kit_VERSION_MAJOR}.${perception_kit_VERSION_MINOR}.${perception_kit_VERSION_PATCH}")
set (libname_major_minor "lib${PROJECT_NAME}.so.${perception_kit_VERSION_MAJOR}.${perception_kit_VERSION_MINOR}")
set (libname_major "lib${PROJECT_NAME}.so.${perception_kit_VERSION_MAJOR}")
set (libname "lib${PROJECT_NAME}.so")
install(CODE "
EXECUTE_PROCESS (COMMAND ln -sf ${libname_major_minor_patch} ${libname_major_minor} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} )
")
install(CODE "
EXECUTE_PROCESS (COMMAND ln -sf ${libname_major_minor_patch} ${libname_major} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} )
")
endif(CMAKE_HOST_UNIX)
最后两个仅在使用make install时创建。有没有办法在不使用make install的情况下制作所有sym链接。 ?
答案 0 :(得分:5)
要执行构建后命令,您可以使用add_custom_command(TARGET ...)
所以在这种情况下,我猜你想要像
这样的东西add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ln -sf ${libname_major_minor_patch} ${libname_major_minor}
COMMAND ln -sf ${libname_major_minor_patch} ${libname_major}
)