diff --git a/CMakeLists.txt b/CMakeLists.txt index 59b3eab4..ce750588 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,17 +263,7 @@ elseif(NOT WIN32) endif() # Magic to convert resources to header files -add_executable(bin2h "src/misc/bin2h.c") - -set_target_properties(bin2h PROPERTIES - C_STANDARD 90 - C_STANDARD_REQUIRED ON - C_EXTENSIONS OFF -) - -if(MSVC) - target_compile_definitions(bin2h PRIVATE _CRT_SECURE_NO_WARNINGS) # Shut up those stupid warnings -endif() +add_subdirectory("bin2h") foreach(FILENAME IN LISTS RESOURCES) set(IN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res") set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/Resource") diff --git a/Makefile b/Makefile index 52c81047..f03e0e10 100644 --- a/Makefile +++ b/Makefile @@ -226,10 +226,10 @@ src/Resource/%.h: res/% obj/bin2h @echo Converting $< @obj/bin2h $< $@ -obj/bin2h: src/misc/bin2h.c +obj/bin2h: bin2h/bin2h.c @mkdir -p $(@D) @echo Compiling $^ - @$(CC) -O3 -s -std=c90 $^ -o $@ + @$(CC) -O3 -s -std=c90 -Wall -Wextra -pedantic $^ -o $@ include $(wildcard $(DEPENDENCIES)) diff --git a/bin2h/CMakeLists.txt b/bin2h/CMakeLists.txt new file mode 100644 index 00000000..f2b1ce9d --- /dev/null +++ b/bin2h/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.7.2) + +if((${CMAKE_VERSION} VERSION_EQUAL 3.9) OR (${CMAKE_VERSION} VERSION_GREATER 3.9)) + cmake_policy(SET CMP0069 NEW) +endif() + +project(bin2h LANGUAGES C) + +add_executable(bin2h "bin2h.c") + +set_target_properties(bin2h PROPERTIES + C_STANDARD 90 + C_STANDARD_REQUIRED ON + C_EXTENSIONS OFF +) + +# MSVC tweak +if(MSVC) + target_compile_definitions(bin2h PRIVATE _CRT_SECURE_NO_WARNINGS) # Shut up those stupid warnings +endif() + +# Enable link-time optimisation if available +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + if((${CMAKE_VERSION} VERSION_EQUAL 3.9) OR (${CMAKE_VERSION} VERSION_GREATER 3.9)) + include(CheckIPOSupported) + check_ipo_supported(RESULT result) + if(result) + set_target_properties(bin2h PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE) + endif() + endif() +endif() diff --git a/src/misc/bin2h.c b/bin2h/bin2h.c similarity index 100% rename from src/misc/bin2h.c rename to bin2h/bin2h.c