gt.sandbox.checkout.commit.cleanly b22d565 \&& cd "$GT_SANDBOX_REPO/cpp/hello-world" \&& cmake -S . -B ./build \&& cd build \&& make \&& ./HelloWorldProjectName.executable
HelloWorld Example CMakeLists.txt
HelloWorldExample CMakeLists.txt
# Min versin cmake checkcmake_minimum_required(VERSION 3.0)# Project nameproject(HelloWorldProjectName)# Add executable target ${PROJECT_NAME}.executable will be the# name of the executable.add_executable(${PROJECT_NAME}.executable hello_world_main.cpp)
Command to reproduce:
gt.sandbox.checkout.commit 65d00c5 \&& cd "${GT_SANDBOX_REPO}/cpp/hello-world" \&& cmd.run.announce "cmake -S . -B ./build && cd build && make && ./HelloWorldProjectName.executable"
Recorded output of command:
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/vintrin/git_repos/glassthought-sandbox/cpp/hello-world/build
[100%] Built target HelloWorldProjectName.executable
Hello World!
Using CMake to install into user level bin directory.
Installing into User Level Bin Directory cmake install
About
cmake install
Allows installation of your executable into widely accessible bin folders such as /usr/local/bin/
Live example using “cmake install”
gt.sandbox.checkout.commit.cleanly 56ae6c2 \&& cd cpp/trim \&& (rm -rf ./build; rm /usr/local/bin/trim-example-app; echo "cleaned") \&& cmake -S . -B ./build \&& cd build \&& make install \&& trim-example-app first second
Sample CMake file with install
Sample CMake with installation
cmake_minimum_required(VERSION 3.0.0)project(TrimProjectName)add_executable(trim-example-app main.cpp)# Just running make will not install the executable.# You need to run## make install## DESTINATION bin will be written to some system defined directory# on MAC for me it ended up in# -- Installing: /usr/local/bin/trim-example-appinstall(TARGETS trim-example-app DESTINATION bin)