Improving CMakeLists.txt thanks to Andy

This commit is contained in:
Daniel Weber 2024-02-22 19:00:48 -05:00
parent eee9b2dc38
commit 6314bc756a

View File

@ -1,21 +1,20 @@
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.8)
set(This Chess) project(Chess C CXX)
project(${This} C CXX)
enable_language(CXX)
# set(SDL2_INCLUDE_DIR /usr/include/SDL2)
# set(SDL2_LIBRARY /usr/lib/x86_64-linux-gnu/libSDL2.so)
# list(APPEND CMAKE_MODULE_PATH SDL2_INCLUDE_DIR)
# list(APPEND CMAKE_MODULE_PATH SDL2_LIBRARY)
#list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2)
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
file(GLOB sources
file(GLOB FILES CONFIGURE_DEPENDS
src/*.cpp) src/*.cpp)
add_executable(${This} ${FILES}) add_executable(Chess ${sources})
include_directories(${SDL2_INCLUDE_DIRS}) set_target_properties(Chess PROPERTIES CXX_STANDARD 17) # set standard level
target_link_libraries(${This} ${SDL2_LIBRARIES}) target_compile_options(Chess PRIVATE
-Wall -Wextra -Wredundant-decls -Wcast-align
-Wshadow -Wnon-virtual-dtor
-Wunused -Woverloaded-virtual -Wpedantic -Wconversion
-Wsign-conversion -Wmisleading-indentation
-Wnull-dereference -Wformat=2
)
target_link_libraries(Chess SDL2::SDL2)