Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR) on CMake
Try installing curl with the dev libraries: sudo apt update && sudo apt upgrade && sudo apt install curl && sudo apt-get install libcurl4-openssl-dev
Try installing curl with the dev libraries: sudo apt update && sudo apt upgrade && sudo apt install curl && sudo apt-get install libcurl4-openssl-dev
Start with a clean directory: /home/user/Desktop/projects/cpp/ # your project lives here Add your cmake file(CMakeLists.txt), your source files, and test file. The directory now looks like this: └─cpp/ ├─ CMakeLists.txt ├─ myfunctions.h └─ mytests.cpp Clone and add googletest to this directory: └─cpp/ ├─ googletest/ ├─ CMakeLists.txt ├─ myfunctions.h └─ mytests.cpp Open your CMakeLists.txt and enter … Read more
How to make a header-only library with cmake? Like this: add_library(project INTERFACE) target_include_directories(project INTERFACE .) Then in the target that uses the library: target_link_libraries(dependee PUBLIC/INTERFACE/PRIVATE # pick one project) and include the header like this: #include <project/folder1/file.hpp>
For CMake 3.20 and newer, the recommended way is to use cmake_path with a PARENT_PATH option: cmake_path(GET MYPROJECT_DIR PARENT_PATH PARENT_DIR) For older versions up to CMake 2.8.12, use the get_filename_component command with the DIRECTORY option: get_filename_component(PARENT_DIR ${MYPROJECT_DIR} DIRECTORY) For versions of CMake older than 2.8.12, use the PATH option: set (MYPROJECT_DIR /dir1/dir2/dir3/myproject/) get_filename_component(PARENT_DIR ${MYPROJECT_DIR} PATH)
A good alternative would be to define a CMake option: OPTION(DEFINE_MACRO “Option description” ON) # Enabled by default Followed by a condition: IF(DEFINE_MACRO) ADD_DEFINITIONS(-DMACRO) ENDIF(DEFINE_MACRO) Then you can turn that option ON/OFF via the command line with CMake using the -D flag. Example: cmake -DDEFINE_MACRO=OFF .. To make sure the compiler is receiving the definition … Read more
For a long time, CMake had the add_definitions command for this purpose. However, recently the command has been superseded by a more fine grained approach (separate commands for compile definitions, include directories, and compiler options). An example using the new add_compile_definitions: add_compile_definitions(OPENCV_VERSION=${OpenCV_VERSION}) add_compile_definitions(WITH_OPENCV2) Or: add_compile_definitions(OPENCV_VERSION=${OpenCV_VERSION} WITH_OPENCV2) The good part about this is that it circumvents … Read more
mingw32-make.exe can be installed with the standard MinGW32 installer via the appropriate checkbox: As rubenvb points out, you’ll still need to ensure that it makes it into your PATH. If you edit your environment variables via System Properties, be sure to close and reopen the CMake GUI. If you’re more accustomed to using make.exe, install … Read more
I had the same problem on Win7. What worked for me is what @Andre suggested in the comment: Right-Click->Properties on cl.exe in your VS install directory (the exact path appears in the CMake error); Choose the Compatibility Tab; Check “Run this program as administrator” in the “Privilege Level” box.
The cmake_minimum_required() function is used to avoid any cryptic error messages due to the CMakeLists.txt assuming a later version of CMake than the one installed on the current host. As an example, failing early, and with a clear message… CMake 3.2 or higher is required. You are running version 2.8.12.2 …is to be preferred over … Read more
Since CMake 3.20 ctest has the option –test-dir for exactly that. –test-dir <dir> Specify the directory in which to look for tests. For CMake older than 3.20: I couldn’t find the way to do it through ctest options, but it is doable using the rule make test which is linked to ctest. In the Makefile … Read more