Skip to content

Commit

Permalink
feat: update CMake config on win branch
Browse files Browse the repository at this point in the history
  • Loading branch information
HangX-Ma committed Jan 24, 2024
1 parent b38a02b commit 387fb99
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++-posix)
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
set(CMAKE_EXE_LINKER_FLAGS "-static")
option(BUILD_STATIC "build output executable using static library")
if(BUILD_STATIC)
message(STATUS "Build with static library")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
set(CMAKE_EXE_LINKER_FLAGS "-static")
endif()

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand All @@ -17,8 +20,23 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# project name
project(dino LANGUAGES CXX C)

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
message(STATUS "Maximum optimization for speed")
add_compile_options(-Ofast)
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
message(STATUS "Maximum optimization for speed, debug info included")
add_compile_options(-Ofast -g)
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
message(STATUS "Maximum optimization for size")
add_compile_options(-s -Os -ffunction-sections -fdata-sections -Wl,--gc-section)
add_compile_options(-fsanitize-address-outline-instrumentation)
else()
message(STATUS "Minimal optimization, debug info included")
add_compile_options(
-Wall # print warning info
-Wextra # print extra warning info
)
add_compile_options(-Og -g)
endif()

add_definitions(-DLGFX_SDL)
Expand All @@ -43,8 +61,7 @@ target_include_directories(
${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/simulator
${CMAKE_CURRENT_SOURCE_DIR}/library/LovyanGFX/src
)
${CMAKE_CURRENT_SOURCE_DIR}/library/LovyanGFX/src)

set(SDL2_LIB_PATH "$ENV{HOME}/SDL2-2.28.5/x86_64-w64-mingw32/lib")
target_include_directories(${PROJECT_NAME} PUBLIC "$ENV{HOME}/SDL2-2.28.5/x86_64-w64-mingw32/include" library/mingw_stdthreads)
Expand Down

0 comments on commit 387fb99

Please # to comment.