-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUESTION]how to use CPM include this project? #386
Comments
I didn't used CPM before, and I did some research. Looks like it needs FetchContent support. However, so far, redis-plus-plus does not support FetchContent feature. So it looks like that you cannot compile it with CPM by now. Regards |
but use add_submodule also can't include, with hiredis be include by add_submodule |
how can i do? just want include you project by src |
What do you mean by including redis-plus-plus by src? B.T.W. instead of FetchContent, you can use ExternalProject feature of cmake to include redis-plus-plus. this issue gives an example, and hope it helpful for you. Regards |
with the issue 1> 命令行: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\redis_cpp\redis_cpp\out\install\x64-Debug" -DVCPKG_TARGET_TRIPLET:STRING="x64-windows" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" "C:\work\redis_cpp\redis_cpp" 2>&1" C:\work\redis_cpp\redis_cpp\out\build\x64-Debug\ninja : error : '../../install/x64-Debug/lib/libredis++.a', needed by 'app.exe', missing and no known rule to make it |
cmake_minimum_required(VERSION 3.14) project(app) include(FetchContent) 用于在cmake低于3.14是使用FetchContent_MakeAvailableset(FetchContentHelp_LOCATION "${PROJECT_SOURCE_DIR}/cmake/FetchContentHelp.cmake") FetchContent_Declare( FetchContent_getproperties(hiredis INSTALL_DIR) FetchContent_Declare( FetchContent_MakeAvailable(redis++) FetchContent_getproperties(redis++ INSTALL_PATH) add_executable(app app.cpp) in this way it work,maybe you can add it to README.md |
FetchContentHelp.cmake: if(${CMAKE_VERSION} VERSION_LESS 3.14) |
Great! Thanks a lot for your work! I'll take a try! Regards |
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project ("redis_cpp")
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
endif()
set(CPM_DOWNLOAD_LOCATION "${PROJECT_SOURCE_DIR}/cmake/CPM.cmake")
set(CPM_GET_CPM_DOWNLOAD_LOCATION "${PROJECT_SOURCE_DIR}/cmake/get_cpm.cmake")
if(NOT EXISTS ${CPM_DOWNLOAD_LOCATION})
message(STATUS "Downloading CPM.cmake")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/CPM.cmake
${CPM_DOWNLOAD_LOCATION})
else()
message(STATUS "CPM.cmake exists pass download")
endif(NOT EXISTS ${CPM_DOWNLOAD_LOCATION})
if(NOT EXISTS ${CPM_GET_CPM_DOWNLOAD_LOCATION})
message(STATUS "Downloading get_cpm.cmake")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
${CPM_GET_CPM_DOWNLOAD_LOCATION})
else()
message(STATUS "get_cpm.cmake exists pass download")
endif(NOT EXISTS ${CPM_GET_CPM_DOWNLOAD_LOCATION})
#启用c++11
set(CMAKE_CXX_STANDARD 11)
include(GNUInstallDirs)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
include(${CPM_DOWNLOAD_LOCATION})
CPMAddPackage(
NAME hiredis # <- use OpenSSL here
GITHUB_REPOSITORY redis/hiredis
GIT_TAG v1.0.2
VERSION v1.0.2
EXCLUDE_FROM_ALL true
OPTIONS
"BUILD_TESTING OFF"
"BUILD_SHARED_LIBS OFF"
"BUILD_STATIC_LIBS ON"
)
包含子项目。
set(ENABLE_SSL OFF)
set(REDIS_PLUS_PLUS_BUILD_STATIC ON)
set(REDIS_PLUS_PLUS_BUILD_SHARED OFF)
set(REDIS_PLUS_PLUS_BUILD_TEST OFF)
add_subdirectory("3rd/redis-plus-plus")
use cmake file like this, but not work。
1> 命令行: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\redis_cpp\redis_cpp\out\install\x64-Debug" -DVCPKG_TARGET_TRIPLET:STRING="x64-windows" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" "C:\work\redis_cpp\redis_cpp" 2>&1"
1> 工作目录: C:\work\redis_cpp\redis_cpp\out\build\x64-Debug
1> [CMake] -- CPM.cmake exists pass download
1> [CMake] -- get_cpm.cmake exists pass download
1> [CMake] -- CPM: adding package [email protected] (v1.0.2)
1> [CMake] Detected version: 1.0.2
1> [CMake] -- redis-plus-plus version: 1.3.5
1> [CMake] -- redis-plus-plus build type: Debug
1> [CMake] -- redis-plus-plus build with CXX standard: c++17
1> [CMake] -- redis-plus-plus TLS support: OFF
1> [CMake] -- redis-plus-plus build static library: ON
1> [CMake] -- redis-plus-plus build static library with position independent code: ON
1> [CMake] -- redis-plus-plus build shared library: OFF
1> [CMake] -- redis-plus-plus build test: OFF
1> [CMake] -- Debian package name: .deb
1> [CMake] -- Configuring done
1> [CMake] CMake Error at 3rd/redis-plus-plus/CMakeLists.txt:162 (target_link_libraries):
1> [CMake] Target "redis++_static" links to:
1> [CMake]
1> [CMake] hiredis::hiredis
1> [CMake]
1> [CMake] but the target was not found. Possible reasons include:
1> [CMake]
1> [CMake] * There is a typo in the target name.
1> [CMake] * A find_package call is missing for an IMPORTED target.
1> [CMake] * An ALIAS target is missing.
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake] -- Generating done
1> [CMake] CMake Generate step failed. Build files cannot be regenerated correctly.
The text was updated successfully, but these errors were encountered: