2022-11-16 09:20:44 +11:00
|
|
|
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
|
2022-10-06 18:57:58 +11:00
|
|
|
project(padlab C)
|
|
|
|
set(TARGET padlab)
|
2022-11-16 04:46:33 +11:00
|
|
|
|
2022-11-18 05:44:30 +11:00
|
|
|
option(USE_OPENGL "Use legacy OpenGL for drawing" ON)
|
|
|
|
|
2022-11-16 09:20:44 +11:00
|
|
|
set(CMAKE_C_STANDARD 99)
|
2023-01-18 23:45:17 +11:00
|
|
|
set(GNU_COMPILERS GNU Clang AppleClang)
|
|
|
|
if (CMAKE_C_COMPILER_ID IN_LIST GNU_COMPILERS)
|
|
|
|
set(GNU 1)
|
2022-11-22 08:01:41 +11:00
|
|
|
elseif (MSVC)
|
|
|
|
string(REPLACE "/W3" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
|
|
|
endif()
|
2022-11-16 09:20:44 +11:00
|
|
|
|
2022-11-16 04:46:33 +11:00
|
|
|
find_package(SDL2 REQUIRED)
|
2022-11-18 05:44:30 +11:00
|
|
|
if (USE_OPENGL)
|
2023-01-18 23:45:17 +11:00
|
|
|
if (NOT DEFINED OpenGL_GL_PREFERENCE)
|
|
|
|
set(OpenGL_GL_PREFERENCE "GLVND")
|
|
|
|
endif()
|
2022-11-18 05:44:30 +11:00
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
endif()
|
2022-11-16 04:46:33 +11:00
|
|
|
|
2022-10-06 18:53:51 +11:00
|
|
|
set(SOURCES
|
2022-11-18 20:53:50 +11:00
|
|
|
src/maths.h
|
|
|
|
src/draw.h src/$<IF:$<BOOL:${USE_OPENGL}>,draw_opengl.c,draw.c>
|
|
|
|
src/stick.c src/stick.h
|
|
|
|
src/analogue.c)
|
2022-10-06 18:53:51 +11:00
|
|
|
|
|
|
|
add_executable(${TARGET} ${SOURCES})
|
2022-11-16 09:20:44 +11:00
|
|
|
target_link_libraries(${TARGET}
|
2022-11-22 08:01:41 +11:00
|
|
|
$<$<PLATFORM_ID:Windows>:SDL2::SDL2main>
|
|
|
|
SDL2::SDL2
|
|
|
|
$<$<BOOL:${USE_OPENGL}>:OpenGL::GL>
|
|
|
|
$<$<BOOL:${GNU}>:m>)
|
2022-10-06 18:53:51 +11:00
|
|
|
target_compile_options(${TARGET} PRIVATE
|
2022-11-22 08:01:41 +11:00
|
|
|
$<$<BOOL:${GNU}>:-Wall -Wextra -pedantic -Wno-unused-parameter>)
|
2022-11-18 05:44:30 +11:00
|
|
|
target_compile_definitions(${TARGET} PRIVATE
|
|
|
|
$<$<BOOL:${USE_OPENGL}>:USE_OPENGL>)
|