How to CMake Good - 0a - Installing on Linux
Why Stack Overflow recommends it
Stack Overflow users link it when answering questions about getting a current CMake on Linux, and also as a starting point for people who want to learn CMake more generally.
Recommended by 3 people across 3 different months, 2019 to 2023.
What it is
An 8-minute screencast by vector-of-bool, the first entry in his 'How to CMake Good' series, showing how to install the latest CMake on Linux using the official installer script. No source compilation or manual file moving is needed, and it targets users stuck on the old version from their distribution's repository.
What people said
Recommends Justin · 2019-01 · Stack Overflow · on “Error trying to use cmake on Ubuntu 16.04”
What if you remove that apt-repository and install via pip ( [LINK] ) or the cmake installer .sh files ( [LINK] , vector-of-bool has a guide on using that [this video] if you need it, but basically just wget the .sh and execute it)?
Recommends LeFish · 2020-03 · Stack Overflow · on “Usage Imagemagick library in C++ Visual Studio Code Project”
I finally have a solution. I installed CMake and the CMake extension for VSCode. According to this tutorial on youtube [this video] I got a functioning development environment. To add an external library to the project I copied all the necessary files to an "include" folder within my project workspace. I made Cmake aware of this folder by the following CMakeLists.txt cmake_minimum_required(VERSION 3.0) project(IMHelloWorld VERSION 1.0.0) add_executable(IMHelloWorld main.cpp) include_directories(${PROJECT_SOURCE_DIR}/include) LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/include) After this I was able to compile the project with cmake .. and cmake --build . as described in the linked videos.
Recommends felixkellenbenz · 2023-08 · Stack Overflow · on “Include compiled library in c++ cmake project”
Since I don't know your concrete directory structure I can only give you a rather generic answer. In your CMakeLists.txt file you need to use the target_include_directories() command. You can find the documentation of this command here ( [LINK] ) also I can recommend you the cmake-good series ( [this video] ), if you want to learn more about CMake. Here is an example of what your CMakeLists.txt file should probably look like: cmake_minimum_required(VERSION 3.25.0) project(myproject) add_library( myproject_object_lib //... ) target_include_directories(myproject_object_lib PUBLIC ${3RDPARTY_DIR}) Here you can find a post on StackOverflow which explains how to include directories more in depth ( How
Cites Ryan · 2019-01 · Stack Overflow · on “Error trying to use cmake on Ubuntu 16.04”
I'm trying to run build dlib on Ubuntu 16.04 using cmake. I had it working before but recently ran into a problem so I uninstalled cmake and tried reinstalling. However, whenever I try to use cmake or check the version via: cmake --version But I get the following error: Traceback (most recent call last): File "/usr/local/bin/cmake", line 11, in <module> load_entry_point('cmake==3.13.3', 'console_scripts', 'cmake')() File "/usr/local/lib/python2.7/dist-packages/cmake-3.13.3-py2.7-linux-x86_64.egg/cmake/__init__.py", line 34, in cmake raise SystemExit(_program('cmake', sys.argv[1:])) File "/usr/local/lib/python2.7/dist-packages/cmake-3.13.3-py2.7-linux-x86_64.egg/cmake/__init__.py", line 30, i
Cites wokay07_ · 2023-01 · Stack Overflow · on “How to specify where CMake is installed in Ubuntu?”
These are the following steps you need to do to upgrade your cmake to the latest version or download cmake if you don't have it: Case 1: I have already have/downloaded cmake on my machine, but I want to upgrade it. If you already have/downloaded cmake before on your machine, then you need to remove it first: sudo apt remove cmake sudo apt purge --auto-remove cmake Case 2: I never have cmake on my machine, but I want download it and I want the latest version. Just proceed to step 2. Download the binary distribution from cmake website [LINK] , for example: cmake-3.25.1-linux-x86_64.sh Inside the directory where you have installed the binary distribution from step 2, run the command below (assu