在 cmake 3.19.2 中,我尝试通过以下方式将分号添加到字符串中:
cmake_minimum_required(VERSION 3.12)
project(some_project)
#--------------------------------------------------------------------
# Set CPP standard
#--------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#--------------------------------------------------------------------
# Create source and headers sets
#--------------------------------------------------------------------
set(SOURCE_FILES)
set(HEADER_FILES)
file( GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp)
file( GLOB_RECURSE HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
add_library(${CMAKE_PROJECT_NAME} STATIC ${SOURCE_FILES})
#--------------------------------------------------------------------
# Generate include list
#--------------------------------------------------------------------
set(INSTALLED_INCLUDES)
foreach(header_path ${HEADER_FILES})
# HERE IM TRYING TO ADD A SEMICOLON BUT IT ALWAYS IGNORED
string(CONCAT path ${INSTALLED_INCLUDES}${header_path}${\;})
set(INSTALLED_INCLUDES ${path})
endforeach()
message(-------------->>>>>${INSTALLED_INCLUDES})
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER ${INSTALLED_INCLUDES}
)
install(TARGETS ${CMAKE_PROJECT_NAME}
PUBLIC_HEADER
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
target_link_libraries(${CMAKE_PROJECT_NAME}
-lboost_regex
-lboost_thread
-lcrypto
-lssl
-pthread
)
但分号总是被忽略。
以下代码也不起作用:
string(CONCAT path ${INSTALLED_INCLUDES}${header_path}\;)
或者
string(CONCAT path ${INSTALLED_INCLUDES}${header_path};)
或者
set(SEM ";")
set(INSTALLED_INCLUDES)
foreach(header_path ${HEADER_FILES})
string(CONCAT path ${INSTALLED_INCLUDES}${header_path}${SEM})
set(INSTALLED_INCLUDES ${path})
endforeach()
Cmake 文档说,什么:“将所有参数连接在一起并将结果存储在命名的 <output_variable> 中。”
我做错了什么?