cmake

Adding header-only dependencies with CMake

两盒软妹~` 提交于 2021-02-05 20:28:33
问题 I have a simple project which requires three header-only libraries in order to compile: websocketpp, spdlog and nlohmann/json. The project structure looks like this: └── src ├── app │ ├── CMakeLists.txt │ ├── src │ └── test ├── CMakeLists.txt ├── core │ ├── CMakeLists.txt │ ├── include │ ├── src │ └── test └── vendor ├── install.cmake ├── nlohmann_json ├── spdlog └── websocketpp The root CMakeLists.txt is as follows: cmake_minimum_required(VERSION 3.6.1 FATAL_ERROR) .. # External 3rd party

cmake - undefined reference to

耗尽温柔 提交于 2021-02-05 12:29:37
问题 I am new to cmake and know this question has been asked before, but still cannot find what I am doing wrong. I have an external library with folders /include and lib . The /include folder contains all the headers ( .h ) and the /lib folder contains all the source ( .c ) files. In my project I have this CMakeList.txt file: cmake_minimum_required(VERSION 3.7) project(FirstAttempt) set(CMAKE_CXX_STANDARD 11) set (EXTRA_LIBS "D:\\libtrading") include_directories(${EXTRA_LIBS}/include) link

cmake - undefined reference to

时光总嘲笑我的痴心妄想 提交于 2021-02-05 12:24:18
问题 I am new to cmake and know this question has been asked before, but still cannot find what I am doing wrong. I have an external library with folders /include and lib . The /include folder contains all the headers ( .h ) and the /lib folder contains all the source ( .c ) files. In my project I have this CMakeList.txt file: cmake_minimum_required(VERSION 3.7) project(FirstAttempt) set(CMAKE_CXX_STANDARD 11) set (EXTRA_LIBS "D:\\libtrading") include_directories(${EXTRA_LIBS}/include) link

How to install only one executable with make install?

与世无争的帅哥 提交于 2021-02-05 10:48:05
问题 I have a project with CMakeLists.txt and 7 executables with it: /Project /build /Subprogram1 /Subprogram2 ... /Subprogram7 CMakeLists.txt My CMakeLists.txt : project(Project) cmake_minimum_required(VERSION 2.8) set( CMAKE_CXX_FLAGS "-O0 -Wall -pedantic -std=c++11" ) include_directories( "${PROJECT_SOURCE_DIR}/headers" ) include_directories( "${PROJECT_SOURCE_DIR}/Subprogram1/headers" ) include_directories( "${PROJECT_SOURCE_DIR}/Subprogram2/headers" ) include_directories( "${PROJECT_SOURCE

gcc 10.1: weird behavior with clang-tidy (clion) and precompiled headers (cmake)

匆匆过客 提交于 2021-02-05 10:28:38
问题 I have had problems with my IDE since an update to GCC 10.1 a few days ago. I use CLion, which uses clang-tidy as linter. I also use the newly introduced command target_precompiled_headers from CMake to use PCH for my project. Unfortunately I get weird linter warning and error messages: That's how I include the header file for my pch in my CMakeLists.txt : target_precompile_headers(Peach PRIVATE ${PROJECT_SOURCE_DIR}/Src/peach_pch.h) Strangely enough, my program compiles perfectly. So the

gcc 10.1: weird behavior with clang-tidy (clion) and precompiled headers (cmake)

蓝咒 提交于 2021-02-05 10:26:35
问题 I have had problems with my IDE since an update to GCC 10.1 a few days ago. I use CLion, which uses clang-tidy as linter. I also use the newly introduced command target_precompiled_headers from CMake to use PCH for my project. Unfortunately I get weird linter warning and error messages: That's how I include the header file for my pch in my CMakeLists.txt : target_precompile_headers(Peach PRIVATE ${PROJECT_SOURCE_DIR}/Src/peach_pch.h) Strangely enough, my program compiles perfectly. So the

In Cmake how to update the makefiles with new source files without cleaning the object files

耗尽温柔 提交于 2021-02-05 09:01:57
问题 I'm using cmake, and I just added new source files and I want to include that new source files in the cmake generated makefiles to include in the building. I tried rebuild_cache but nothing happens. Thanks! 回答1: It depends how your cmake file was built. If you use GLOB, you must run cmake manually any time you add or remove a source file. If you explicitly list your source files, just run make again. CMake will detect the changed CMakeLists.text. CMake suggests the latter for this reason: We

In Cmake how to update the makefiles with new source files without cleaning the object files

时间秒杀一切 提交于 2021-02-05 09:01:34
问题 I'm using cmake, and I just added new source files and I want to include that new source files in the cmake generated makefiles to include in the building. I tried rebuild_cache but nothing happens. Thanks! 回答1: It depends how your cmake file was built. If you use GLOB, you must run cmake manually any time you add or remove a source file. If you explicitly list your source files, just run make again. CMake will detect the changed CMakeLists.text. CMake suggests the latter for this reason: We

Linking Crypto++ fails when building a C++ project using CMake

冷暖自知 提交于 2021-02-05 08:00:07
问题 I have the following project structure: myexec/ |-main.cpp |-hashing.cpp |-hashing.h |-CMakeLists.txt My little software needs Crypto++ whose latest version I built under this path: C:\Users\myuser\cryptopp CMakeLists.txt is: cmake_minimum_required (VERSION 3.8) project ("MyExec") add_executable(MyExec "main.cpp", "hashing.h", "hashing.cpp") find_library(CRYPTOPP_LIB cryptopp "C:/Users/myuser/cryptopp/Win32/DLL_Output/Debug") target_link_libraries(MyExec PUBLIC "${CRYPTOPP_LIB}") target

cmake detect which library libc++ or libstdc++ is configured to be used against g++ or clang++

╄→гoц情女王★ 提交于 2021-02-05 06:43:05
问题 I wrote an CMakeLists.txt to build a project with either g++ or clang++ . To catch as many as possible bugs I use both libc++ with -D_LIBCPP_DEBUG2=2 (for clang++ ) and libstdc++ with -D_GLIBCXX_DEBUG (for both g++ and clang++ ). set(CMAKE_CXX_FLAGS_DEBUG "-ggdb -fno-inline -DDEBUG=1 -march=x86-64 -mtune=generic") #[[ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_LIBCPP_DEBUG2=2") elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") set