Removed bin2h mentions in CMakeLists, moved warnings options and FORCE_LOCAL_LIBS into a seperate block where the descriptions were improved and added warnings to DoConfig

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
This commit is contained in:
Gabriel Ravier 2019-10-29 10:03:13 +01:00
parent 01abc0541a
commit d40376ff35
2 changed files with 90 additions and 6 deletions

View file

@ -9,13 +9,14 @@ set(ASSETS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets")
option(JAPANESE "Enable the Japanese-language build" OFF) option(JAPANESE "Enable the Japanese-language build" OFF)
option(FIX_BUGS "Fix various bugs in the game" OFF) option(FIX_BUGS "Fix various bugs in the game" OFF)
option(WARNINGS "Enable common warnings" OFF)
option(ALL_WARNINGS "Enable ALL warnings (clang/MSVC-only)" OFF)
option(FATAL_WARNINGS "Stop compilation on any warnings" OFF)
option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the window" OFF) option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the window" OFF)
option(FORCE_LOCAL_LIBS "Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones" OFF)
set(RENDERER "SDLTexture" CACHE STRING "Which renderer the game should use: 'OpenGL3' for an OpenGL 3.2 renderer, 'SDLTexture' for SDL2's hardware-accelerated Texture API, 'SDLSurface' for SDL2's software-rendered Surface API, or 'Software' for a handwritten software renderer") set(RENDERER "SDLTexture" CACHE STRING "Which renderer the game should use: 'OpenGL3' for an OpenGL 3.2 renderer, 'SDLTexture' for SDL2's hardware-accelerated Texture API, 'SDLSurface' for SDL2's software-rendered Surface API, or 'Software' for a handwritten software renderer")
option(WARNINGS "Enable common compiler warnings (for gcc-compatible compilers and MSVC only)" OFF)
option(ALL_WARNINGS "Enable ALL compiler warnings (for clang and MSVC only)" OFF)
option(FATAL_WARNINGS "Stop compilation on any compiler warning (for gcc-compatible compilers and MSVC only)" OFF)
option(FORCE_LOCAL_LIBS "Compile the built-in versions of SDL2, FreeType, and FLTK instead of using the system-provided ones" OFF)
project(CSE2 LANGUAGES C CXX) project(CSE2 LANGUAGES C CXX)
message(STATUS "Compiler ID : ${CMAKE_CXX_COMPILER_ID}") message(STATUS "Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
@ -323,10 +324,8 @@ if (FATAL_WARNINGS)
if (MSVC) if (MSVC)
target_compile_options(CSE2 PRIVATE /WX) target_compile_options(CSE2 PRIVATE /WX)
target_compile_options(bin2h PRIVATE /WX)
elseif(COMPILER_IS_GCC_COMPATIBLE) elseif(COMPILER_IS_GCC_COMPATIBLE)
target_compile_options(CSE2 PRIVATE -Werror) target_compile_options(CSE2 PRIVATE -Werror)
target_compile_options(bin2h PRIVATE -Werror)
else() else()
message(WARNING "Could not activate fatal warnings ! (Unsupported compiler)") message(WARNING "Could not activate fatal warnings ! (Unsupported compiler)")
endif() endif()
@ -513,6 +512,11 @@ endif()
# DoConfig # DoConfig
## ##
# Set warning options for DoConfig
set(WARNINGS ${WARNINGS} FORCE BOOL)
set(ALL_WARNINGS ${ALL_WARNINGS} FORCE BOOL)
set(FATAL_WARNINGS ${FATAL_WARNINGS} FORCE BOOL)
add_subdirectory("DoConfig") add_subdirectory("DoConfig")
# Name debug builds "DoConfig_debug", to distinguish them # Name debug builds "DoConfig_debug", to distinguish them

View file

@ -8,8 +8,88 @@ option(FORCE_LOCAL_LIBS "Compile the built-in version of FLTK instead of using t
project(DoConfig LANGUAGES CXX) project(DoConfig LANGUAGES CXX)
message(STATUS "Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
# Has to be placed after "project()"
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Using Clang (this is a match so that we also get "AppleClang" which is the Apple-provided Clang
set(COMPILER_IS_CLANG true)
message(STATUS "Compiling with clang")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Using GCC
set(COMPILER_IS_GCC true)
message(STATUS "Compiling with gcc")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# Using Intel C++
set(COMPILER_IS_ICC true)
message(STATUS "Compiling with ICC")
endif()
if (COMPILER_IS_CLANG OR COMPILER_IS_GCC OR COMPILER_IS_ICC)
set(COMPILER_IS_GCC_COMPATIBLE true)
message(STATUS "Compiling with a GCC-compatible compiler")
endif()
add_executable(DoConfig "DoConfig.cpp" "icon.rc") add_executable(DoConfig "DoConfig.cpp" "icon.rc")
if (WARNINGS)
# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
if (MSVC)
# Force to always compile with /W4 on MSVC
# Can't do this with target_compile_options
# if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
# string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# else()
# target_compile_options(CSE2 PRIVATE /W4)
# endif()
target_compile_options(DoConfig PRIVATE /W4)
elseif(COMPILER_IS_GCC_COMPATIBLE)
target_compile_options(DoConfig PRIVATE -Wall -Wextra -pedantic)
else()
message(WARNING "Could not activate warnings ! (Unsupported compiler)")
endif()
endif()
if (ALL_WARNINGS)
# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
if (MSVC)
# Force to always compile with /Wall on MSVC
# Can't do this with target_compile_options
# if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
# string(REGEX REPLACE "/W[0-4]" "/Wall" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# else()
# target_compile_options(CSE2 PRIVATE /Wall)
# endif()
target_compile_options(DoConfig PRIVATE /Wall)
elseif(COMPILER_IS_CLANG)
target_compile_options(DoConfig PRIVATE -Weverything)
else()
message(WARNING "Could not activate all warnings ! (Unsupported compiler)")
endif()
endif()
if (FATAL_WARNINGS)
# HACK : Replace this with CMake provided stuff when possible (when CMake makes avoiding this possible (it isn't currently))
if (MSVC)
target_compile_options(DoConfig PRIVATE /WX)
elseif(COMPILER_IS_GCC_COMPATIBLE)
target_compile_options(DoConfig PRIVATE -Werror)
else()
message(WARNING "Could not activate fatal warnings ! (Unsupported compiler)")
endif()
endif()
# Windows tweak # Windows tweak
if(WIN32) if(WIN32)
set_target_properties(DoConfig PROPERTIES WIN32_EXECUTABLE YES) # Disable the console window set_target_properties(DoConfig PROPERTIES WIN32_EXECUTABLE YES) # Disable the console window