diff --git a/CMakeLists.txt b/CMakeLists.txt index 404b1b6..ddf1fc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fdf134c..7850f27 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 $<$:m>) + set_target_properties(${_TARGET} PROPERTIES + C_STANDARD 99 + WIN32_EXECUTABLE ON) + set(GNU $,$,$>) + target_link_libraries(${_TARGET} SDL3::SDL3 $<${GNU}:m>) target_compile_options(${_TARGET} PRIVATE - $<$:-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()