Skip to content

Instantly share code, notes, and snippets.

@iondune
Created April 5, 2017 19:26
Show Gist options
  • Save iondune/b75501189e027c886ac12afee1274f0e to your computer and use it in GitHub Desktop.
Save iondune/b75501189e027c886ac12afee1274f0e to your computer and use it in GitHub Desktop.
Basic CPP CMakeLists Template
cmake_minimum_required(VERSION 2.8)
# Name of the project
project(raytrace)
# Use glob to get the list of all source files.
file(GLOB_RECURSE SOURCES "src/*.cpp")
# We don't really need to include header and resource files to build, but it's
# nice to have them show up in IDEs.
file(GLOB_RECURSE HEADERS "src/*.h")
# Set the executable.
add_executable(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS})
# OS specific options and libraries
if(WIN32)
# c++0x is enabled by default.
# -Wall produces way too many warnings.
# -pedantic is not supported.
# Disable warning 4996.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
else()
# Enable all pedantic warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic")
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment