它们都是最新版本。
CMakeLists.txt是:
project(xeditd LANGUAGES CXX VERSION 0.1)
find_package(PkgConfig REQUIRED)
pkg_search_module(ICU_UC icu-uc)
pkg_search_module(SPDLOG spdlog)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ICU_UC_CXXFLAGS_OTHER}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SPDLOG_CXXFLAGS_OTHER}")
set(SRC_FILE
xeditd.cpp
)
set(LIB_DIR
${ICU_UC_LIBRARY_DIRS}
${SPDLOG_LIBRARY_DIRS}
)
set(LIB
${ICU_UC_LIBRARIES}
${SPDLOG_LIBRARIES}
)
set(INC_DIR
${ICU_UC_INCLUDE_DIRS}
${SPDLOG_INCLUDE_DIRS}
)
message(ICU_UC_CXXFLAGS_OTHER: ${ICU_UC_CXXFLAGS_OTHER})
message(SPDLOG_CXXFLAGS_OTHER: ${SPDLOG_CXXFLAGS_OTHER})
message(ICU_UC_LIBRARY_DIRS: ${ICU_UC_LIBRARY_DIRS})
message(SPDLOG_LIBRARY_DIRS: ${SPDLOG_LIBRARY_DIRS})
message(ICU_UC_LIBRARIES: ${ICU_UC_LIBRARIES})
message(SPDLOG_LIBRARIES: ${SPDLOG_LIBRARIES})
message(ICU_UC_INCLUDE_DIRS: ${ICU_UC_INCLUDE_DIRS})
message(SPDLOG_INCLUDE_DIRS: ${SPDLOG_INCLUDE_DIRS})
link_directories(${LIB_DIR})
add_executable(xeditd ${SRC_FILE})
target_include_directories(xeditd PUBLIC ${INC_DIR})
target_link_libraries(xeditd ${LIB})
消息显示:
ICU_UC_CXXFLAGS_OTHER:
SPDLOG_CXXFLAGS_OTHER:
ICU_UC_LIBRARY_DIRS:/usr/local/Cellar/icu4c/64.2/lib
SPDLOG_LIBRARY_DIRS:
ICU_UC_LIBRARIES:icuucicudata
SPDLOG_LIBRARIES:
ICU_UC_INCLUDE_DIRS:/usr/local/Cellar/icu4c/64.2/include
SPDLOG_INCLUDE_DIRS:
找不到头文件<spdlog/spdlog.h>
。显然,cmake中不包含spdlog标头目录。
为什么pkg_search_module适用于icu4c
,但错误不适用于spdlog
?而不是pthread
吗?
答案 0 :(得分:0)
IF(APPLE)
FIND_PACKAGE(spdlog REQUIRED)
ENDIF(APPLE)
...
# Translation is your traget
IF(APPLE)
target_link_libraries(Translation PUBLIC spdlog::spdlog)
ENDIF(APPLE)