Skip to content

cpporchard/cmake_project_template

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Topics Covered

  1. CMake Simple Project Link
  2. CMake + Gtest (via Git Submodule) Link
  3. CMake + Boost Simple + GTest (via Git Submodule) Link*
  4. CMake + Boost Http Server Executable (via Git Submodule) Link*
  5. CMake + Gtest (via FetchContent)

'Link*' means popular project template.

Commands

Add Library

  • Google Test
git submodule add https://github.com/google/googletest.git third_party/googletest
git submodule update --init --recursive
  • Boost

we noticed that we might need to download whole boost library to include just a subset of boost. We cd into boost and do --init --recursive to pull all the submodules inside boost.

git submodule add https://github.com/boostorg/boost.git third_party/boost
cd third_party/boost
git submodule update --init --recursive

Removing Previous Sub Module (Optional)

# commit or stash your changes b
git submodule deinit -f third_party/googletest
rm -rf .git/modules/third_party/googletest
rm -rf third_party/googletest

git config --file=.gitmodules --remove-section submodule.third_party/googletest
git config --file=.git/config --remove-section submodule.third_party/googletest
git rm --cached third_party/googletest

rm -rf .git/modules/*
rm -rf third_party
rm -rf .gitmodules

Build

  • Remove Previous Build (You won't make use of incremental build)
rm -rf build
  • Build third_party, src and test.
mkdir build && cd build
cmake ..
make -j$(nproc --all)

Run

  • Run Unit Test
cd build
./unittest/VectorTest
  • Run Executable
./build/src/HttpServer
🚀 Starting HTTP server on http://localhost:8080 ...


curl "http://localhost:8080/split?text=hi,there,test&delim=,"
["hi", "there", "test"]

FAQ

If CLion doesn't detect the Project as CMake.

Remove the .idea folder and reopen the CMake Project.

About

CMake, Google Test, Boost Http Server, Git Submodule, CMake FetchContent

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published