Files
spaceshipsim/CMakeLists.txt

81 lines
2.3 KiB
CMake
Raw Normal View History

# Copyright (C) 2026 Ortega Froysa, Nicolás <nicolas@ortegas.org>
# Author: Ortega Froysa, Nicolás <nicolas@ortegas.org>
2018-03-25 12:08:19 +02:00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.10)
2026-03-31 11:17:27 +02:00
project(spaceshipsim
VERSION 0.6
SPDX_LICENSE "GPL-3.0-or-later"
DESCRIPTION "A simulation of a 2D space ship in the frictionless environment of space."
HOMEPAGE_URL "https://code.ortegas.org/nortega/spaceshipsim"
LANGUAGES C)
2018-03-25 12:08:19 +02:00
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "release")
endif()
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
set(CMAKE_C_FLAGS "-std=c99 -Wall -Wextra -Werror")
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O3 -ffast-math")
2018-03-25 12:08:19 +02:00
set(CMAKE_C_FLAGS_MINSIZEREL "-Os")
2018-03-25 12:30:39 +02:00
find_package(PkgConfig REQUIRED)
2018-04-13 08:01:53 +02:00
pkg_check_modules(ALLEG5 REQUIRED allegro-5>=5.1.9)
pkg_check_modules(ALLEG5-PRIM REQUIRED allegro_primitives-5)
pkg_check_modules(ALLEG5-FONT REQUIRED allegro_font-5)
2018-03-25 12:30:39 +02:00
include_directories(
SYSTEM ${ALLEG5_INCLUDE_DIRS})
2018-03-25 12:08:19 +02:00
set(SRCS
2026-03-31 11:17:27 +02:00
"src/event_manager.c"
"src/main.c"
"src/planet.c"
"src/ship.c"
"src/starfield.c"
)
set(HDRS
"src/event_manager.h"
"src/globals.h"
"src/planet.h"
"src/ship.h"
"src/starfield.h"
)
2018-03-25 12:08:19 +02:00
2026-03-31 11:17:27 +02:00
add_definitions(-DVERSION="${PROJECT_VERSION}")
2018-03-25 12:08:19 +02:00
2026-03-03 09:37:47 +01:00
if(${CMAKE_BUILD_TYPE} STREQUAL "debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "relwithdebinfo")
2018-03-25 12:08:19 +02:00
add_definitions(-DDEBUG)
else()
add_definitions(-DNDEBUG)
endif()
2026-03-31 11:17:27 +02:00
add_executable(${PROJECT_NAME} ${SRCS} ${HDRS})
2018-03-25 12:08:19 +02:00
2026-03-31 11:17:27 +02:00
target_link_libraries(${PROJECT_NAME}
m # math library
2018-03-25 12:30:39 +02:00
${ALLEG5_LIBRARIES}
${ALLEG5-PRIM_LIBRARIES}
${ALLEG5-FONT_LIBRARIES})
2018-03-25 12:08:19 +02:00
2026-03-31 11:17:27 +02:00
install(TARGETS ${PROJECT_NAME}
2018-03-25 12:30:39 +02:00
RUNTIME DESTINATION bin/
CONFIGURATIONS release minsizerel)