Skip to content

Instantly share code, notes, and snippets.

@arash28134
Created September 12, 2023 18:37
Show Gist options
  • Save arash28134/92c0e332aeb72429d321d4ddb44174e1 to your computer and use it in GitHub Desktop.
Save arash28134/92c0e332aeb72429d321d4ddb44174e1 to your computer and use it in GitHub Desktop.
Example CMakeLists.txt for basic projects
# File strcuture:
#
# Test Project/
# ├─ CMakeLists.txt
# ├─ src/
# │ ├─ *.cpp
# ├─ include/
# │ ├─ *.h
# │ ├─ *.hpp
cmake_minimum_required(VERSION 3.14)
project(test) # <--- Your project name
set(CMAKE_CXX_STANDARD 20)
set(SOURCE_DIR ${PROJECT_SOURCE_DIR}/src)
set(HEADER_DIR ${PROJECT_SOURCE_DIR}/include)
file(GLOB_RECURSE SOURCE_FILES ${SOURCE_DIR}/*.cpp)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
target_include_directories(${PROJECT_NAME} PRIVATE ${HEADER_DIR})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment