mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Add DEVELOP option to CMake
This requires CMake 3.0 so -Werror won't conflict with link tests. Remove all version checks to improve simplicity.
This commit is contained in:
@@ -6,33 +6,16 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
#
|
#
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8.8)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
cmake_policy(VERSION 3.0)
|
||||||
|
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
project(rgbds
|
||||||
|
LANGUAGES C)
|
||||||
|
|
||||||
set(RGBDS_VER 0.4.1)
|
option(DEVELOP "build in development mode" OFF)
|
||||||
set(RGBDS_DESC "Rednex Game Boy Development System")
|
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.0)
|
|
||||||
project(rgbds C)
|
|
||||||
set(PROJECT_VERSION "${RGBDS_VER}")
|
|
||||||
else()
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.9)
|
|
||||||
project(rgbds VERSION "${RGBDS_VER}"
|
|
||||||
LANGUAGES C)
|
|
||||||
else()
|
|
||||||
project(rgbds VERSION "${RGBDS_VER}"
|
|
||||||
DESCRIPTION "${RGBDS_DESC}"
|
|
||||||
LANGUAGES C)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.9)
|
|
||||||
set(PROJECT_DESCRIPTION "${RGBDS_DESC}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(DEFAULT_BUILD_TYPE "Release")
|
set(DEFAULT_BUILD_TYPE "Release")
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE AND NOT DEVELOP)
|
||||||
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}")
|
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -53,10 +36,32 @@ find_package(FLEX)
|
|||||||
|
|
||||||
include_directories("${PROJECT_SOURCE_DIR}/include")
|
include_directories("${PROJECT_SOURCE_DIR}/include")
|
||||||
|
|
||||||
|
if(DEVELOP)
|
||||||
|
add_definitions(-DDEVELOP)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W1 /MP -D_CRT_SECURE_NO_WARNINGS")
|
add_compile_options(/W1 /MP)
|
||||||
|
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
|
||||||
else()
|
else()
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic")
|
if(DEVELOP)
|
||||||
|
add_compile_options(-Werror -Wall -Wextra -pedantic
|
||||||
|
-Wno-sign-compare -Wformat -Wformat-security -Wformat-overflow=2
|
||||||
|
-Wformat-truncation=1 -Wformat-y2k -Wswitch-enum -Wunused
|
||||||
|
-Wuninitialized -Wunknown-pragmas -Wstrict-overflow=5
|
||||||
|
-Wstringop-overflow=4 -Walloc-zero -Wduplicated-cond
|
||||||
|
-Wfloat-equal -Wshadow -Wcast-qual -Wcast-align -Wlogical-op
|
||||||
|
-Wnested-externs -Wno-aggressive-loop-optimizations -Winline
|
||||||
|
-Wundef -Wstrict-prototypes -Wold-style-definition)
|
||||||
|
|
||||||
|
link_libraries(-fsanitize=shift -fsanitize=integer-divide-by-zero
|
||||||
|
-fsanitize=unreachable -fsanitize=vla-bound
|
||||||
|
-fsanitize=signed-integer-overflow -fsanitize=bounds
|
||||||
|
-fsanitize=object-size -fsanitize=bool -fsanitize=enum
|
||||||
|
-fsanitize=alignment -fsanitize=null)
|
||||||
|
else()
|
||||||
|
add_compile_options(-Wall -pedantic)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Use versioning consistent with Makefile
|
# Use versioning consistent with Makefile
|
||||||
@@ -67,11 +72,7 @@ execute_process(COMMAND git describe --tags --dirty --always
|
|||||||
ERROR_QUIET)
|
ERROR_QUIET)
|
||||||
string(STRIP "${GIT_REV}" GIT_REV)
|
string(STRIP "${GIT_REV}" GIT_REV)
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.12)
|
add_definitions(-DBUILD_VERSION_STRING="${GIT_REV}")
|
||||||
add_definitions(-DBUILD_VERSION_STRING="${GIT_REV}")
|
|
||||||
else()
|
|
||||||
add_compile_definitions(BUILD_VERSION_STRING="${GIT_REV}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED True)
|
set(CMAKE_C_STANDARD_REQUIRED True)
|
||||||
|
|||||||
@@ -17,23 +17,12 @@ BISON_TARGET(ASMy "asm/asmy.y"
|
|||||||
DEFINES_FILE "${PROJECT_SOURCE_DIR}/src/asm/asmy.h"
|
DEFINES_FILE "${PROJECT_SOURCE_DIR}/src/asm/asmy.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Lexer is not present yet
|
|
||||||
if(False) # FLEX_FOUND
|
|
||||||
FLEX_TARGET(Lexer "asm/lexer.l"
|
|
||||||
"${PROJECT_SOURCE_DIR}/src/asm/lexer.c"
|
|
||||||
)
|
|
||||||
ADD_FLEX_BISON_DEPENDENCY(Lexer ASMy)
|
|
||||||
set(Lexer_SOURCE "${FLEX_Lexer_OUTPUTS}")
|
|
||||||
else()
|
|
||||||
set(Lexer_SOURCE "asm/lexer.c")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(rgbasm_src
|
set(rgbasm_src
|
||||||
"${BISON_ASMy_OUTPUT_SOURCE}"
|
"${BISON_ASMy_OUTPUT_SOURCE}"
|
||||||
"${Lexer_SOURCE}"
|
|
||||||
"asm/charmap.c"
|
"asm/charmap.c"
|
||||||
"asm/fstack.c"
|
"asm/fstack.c"
|
||||||
"asm/globlex.c"
|
"asm/globlex.c"
|
||||||
|
"asm/lexer.c"
|
||||||
"asm/macro.c"
|
"asm/macro.c"
|
||||||
"asm/main.c"
|
"asm/main.c"
|
||||||
"asm/math.c"
|
"asm/math.c"
|
||||||
@@ -79,22 +68,12 @@ foreach(PROG "asm" "fix" "gfx" "link")
|
|||||||
install(TARGETS rgb${PROG} RUNTIME DESTINATION bin)
|
install(TARGETS rgb${PROG} RUNTIME DESTINATION bin)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 2.8.12)
|
target_compile_definitions(rgbgfx PRIVATE ${PNG_DEFINITIONS})
|
||||||
add_definitions(${PNG_DEFINITIONS})
|
target_include_directories(rgbgfx PRIVATE ${PNG_INCLUDE_DIRS})
|
||||||
include_directories(${PNG_INCLUDE_DIRS})
|
target_link_libraries(rgbgfx PRIVATE ${PNG_LIBRARIES})
|
||||||
target_link_libraries(rgbgfx ${PNG_LIBRARIES})
|
|
||||||
else()
|
|
||||||
target_compile_definitions(rgbgfx PRIVATE ${PNG_DEFINITIONS})
|
|
||||||
target_include_directories(rgbgfx PRIVATE ${PNG_INCLUDE_DIRS})
|
|
||||||
target_link_libraries(rgbgfx PRIVATE ${PNG_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(CheckLibraryExists)
|
include(CheckLibraryExists)
|
||||||
check_library_exists("m" "sin" "" HAS_LIBM)
|
check_library_exists("m" "sin" "" HAS_LIBM)
|
||||||
if(HAS_LIBM)
|
if(HAS_LIBM)
|
||||||
if(CMAKE_VERSION VERSION_LESS 2.8.12)
|
target_link_libraries(rgbasm PRIVATE "m")
|
||||||
target_link_libraries(rgbasm LINK_PRIVATE "m")
|
|
||||||
else()
|
|
||||||
target_link_libraries(rgbasm PRIVATE "m")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user