Skip to content

Instantly share code, notes, and snippets.

@thejoeejoee
Last active November 29, 2017 18:25
Show Gist options
  • Save thejoeejoee/f004ccd3901a6f31dfb941d81f565b0e to your computer and use it in GitHub Desktop.
Save thejoeejoee/f004ccd3901a6f31dfb941d81f565b0e to your computer and use it in GitHub Desktop.
CMake with globs
cmake_minimum_required(VERSION 3.0)
project(main)
IF (CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -pedantic -std=c99 -Wno-unused-parameter -Wno-variadic-macros")
ELSEIF (MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D_CRT_SECURE_NO_WARNINGS /wd4200")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /wd4200")
ENDIF ()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)
# sources
file(
GLOB_RECURSE SRC
LIST_DIRECTORIES false
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"src/*.c" "src/*.h"
)
add_executable(main ${SRC})
IF (NOT MSVC)
target_link_libraries(main m)
ENDIF ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment