windows project tweaks

This commit is contained in:
2024-03-10 20:39:38 +11:00
parent 123d228e14
commit 888ddbcd43
2 changed files with 11 additions and 7 deletions

View File

@ -7,11 +7,7 @@ option(BUILD_METAL "Build executable using Metal for drawing (WIP)" ${APPLE})
option(BUILD_OPENGL "Build OpenGL 3.3 core profile executable (WIP)" OFF)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_C_STANDARD 99)
set(GNU_COMPILERS GNU Clang AppleClang)
if (CMAKE_C_COMPILER_ID IN_LIST GNU_COMPILERS)
set(GNU 1)
elseif (MSVC)
if (CMAKE_GENERATOR MATCHES "Visual Studio")
string(REPLACE "/W3" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
endif()

View File

@ -11,9 +11,13 @@ set(SOURCES_OPENGL glcore/draw_opengl_core.c)
set(SOURCES_OPENGL_LEGACY gl/draw_opengl.c)
function (common_setup _TARGET)
target_link_libraries(${_TARGET} SDL3::SDL3 $<$<BOOL:${GNU}>:m>)
set_target_properties(${_TARGET} PROPERTIES
C_STANDARD 99
WIN32_EXECUTABLE ON)
set(GNU $<OR:$<C_COMPILER_ID:GNU>,$<C_COMPILER_ID:Clang>,$<C_COMPILER_ID:AppleClang>>)
target_link_libraries(${_TARGET} SDL3::SDL3 $<${GNU}:m>)
target_compile_options(${_TARGET} PRIVATE
$<$<BOOL:${GNU}>:-Wall -Wextra -pedantic -Wno-unused-parameter>)
$<${GNU}:-Wall -Wextra -pedantic -Wno-unused-parameter>)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
get_property(SDL3_IMPORTED_LOCATION TARGET SDL3::SDL3 PROPERTY IMPORTED_LOCATION)
if (SDL3_IMPORTED_LOCATION MATCHES "^/Library/Frameworks/")
@ -62,3 +66,7 @@ if (BUILD_OPENGL_LEGACY)
target_compile_definitions(${TARGET}_gl PRIVATE USE_OPENGL)
common_setup(${TARGET}_gl)
endif()
if (CMAKE_GENERATOR MATCHES "Visual Studio")
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TARGET})
endif()