Skip to content

Commit

Permalink
Use target_compile_features
Browse files Browse the repository at this point in the history
  • Loading branch information
melroy89 committed Dec 17, 2023
1 parent 47e6525 commit 570e4b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
include(Packaging)
endif()

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED YES)
set(CMAKE_C_EXTENSIONS NO)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CYGWIN)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()

if(WIN32)
set(WINDOWS_FLAGS -mwindows)
endif()
Expand Down
13 changes: 13 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ if(NOT UNITTEST)
target_compile_definitions(${PROJECT_TARGET} PRIVATE __linux__)
endif()

# Set C++20
target_compile_features(${PROJECT_TARGET} PUBLIC cxx_std_20)
set_target_properties(${PROJECT_TARGET} PROPERTIES CXX_EXTENSIONS OFF)
# Set C99
target_compile_features(${PROJECT_TARGET} PUBLIC c_std_99)

# Add fallback for std filesystem in older GCC versions
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.4)
Expand Down Expand Up @@ -204,6 +210,13 @@ else()
add_library(${PROJECT_TARGET_LIB}-file STATIC file.h file.cc)
add_library(${PROJECT_TARGET_LIB}-draw STATIC draw.h draw.cc md-parser.h md-parser.cc)
add_library(${PROJECT_TARGET_LIB}-parser STATIC md-parser.h md-parser.cc)

# Set C++20
target_compile_features(${PROJECT_TARGET_LIB} PUBLIC cxx_std_20)
set_target_properties(${PROJECT_TARGET_LIB} PROPERTIES CXX_EXTENSIONS OFF)
# Set C99
target_compile_features(${PROJECT_TARGET_LIB} PUBLIC c_std_99)

# Only link/include external libs we really need for the unittest libaries
target_include_directories(${PROJECT_TARGET_LIB}-draw PRIVATE
${CMARK_BINARY_DIR}
Expand Down

0 comments on commit 570e4b6

Please sign in to comment.