kge/CMakeLists.txt

126 lines
3.1 KiB
CMake
Raw Normal View History

2023-10-09 05:00:50 +00:00
cmake_minimum_required(VERSION 3.22)
project(kge
DESCRIPTION "kyle's editor"
LANGUAGES CXX
VERSION 0.0.1)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2023-10-11 23:27:03 +00:00
set(CMAKE_VERBOSE_MAKEFILES TRUE)
set(VERBOSE YES)
2023-10-11 05:23:12 +00:00
string(TIMESTAMP TODAY "%Y%m%d")
2023-10-09 05:00:50 +00:00
####################
### BUILD CONFIG ###
####################
# in "prod", this will be ON by default; the docstring is written this
# way as I am likely to forget to change it later.
set(BUILD_GUI OFF CACHE BOOL "Disable building the graphical version.")
2023-10-09 10:19:09 +00:00
if (CMAKE_HOST_UNIX)
message(STATUS "Build system is POSIX.")
else ()
message(STATUS "Build system is NOT POSIX.")
endif ()
if (MSVC)
add_compile_options("/W4" "$<$<CONFIG:RELEASE>:/O2>")
else ()
add_compile_options(
"-Wall"
"-Wextra"
"-Werror"
"-static"
"$<$<CONFIG:DEBUG>:-g>"
"$<$<CONFIG:RELEASE>:-O2>")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options("-stdlib=libc++")
else ()
# nothing special for gcc at the moment
endif ()
endif ()
2023-10-12 00:57:48 +00:00
add_compile_definitions(KGE_PLATFORM=${CMAKE_HOST_SYSTEM_NAME})
add_compile_definitions(KGE_VERSION=${PROJECT_VERSION})
message(STATUS "Build system: ${CMAKE_HOST_SYSTEM_NAME}")
2023-10-09 05:00:50 +00:00
if (${BUILD_GUI})
include(cmake/imgui.cmake)
endif ()
#####################
### BUILD TARGETS ###
#####################
set(HEADER_FILES
Defs.h
Buffer.h
File.h
Cursor.h
2023-10-15 06:28:43 +00:00
Frame.h
)
set(SOURCE_FILES
Defs.cc
Buffer.cc
File.cc
Cursor.cc
2023-10-15 06:28:43 +00:00
Frame.cc
2023-10-09 10:19:09 +00:00
)
add_executable(ke main.cc ${SOURCE_FILES} ${HEADER_FILES})
2023-10-11 05:23:12 +00:00
if (CMAKE_HOST_UNIX)
add_custom_target(manpages)
configure_file(docs/ke.md ke.1.scdoc @ONLY)
add_custom_command(TARGET manpages COMMAND scdoc < ke.1.scdoc > ke.1
OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/ke.1)
add_dependencies(ke manpages)
endif ()
if (${BUILD_GUI})
configure_file(resources/kge.desktop.in kge.desktop @ONLY)
add_executable(kge gmain.cc ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries(kge imgui)
add_dependencies(kge ke)
if (CMAKE_HOST_UNIX)
configure_file(docs/kge.md kge.1.scdoc @ONLY)
add_custom_command(TARGET manpages COMMAND scdoc < kge.1.scdoc > kge.1
OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/kge.1)
add_dependencies(kge manpages)
endif ()
endif ()
#######################
### INSTALL TARGETS ###
#######################
install(TARGETS ke
DESTINATION bin
COMPONENT nox)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ke.1
DESTINATION share/man/man1
COMPONENT nox)
if (${BUILD_GUI})
install(TARGETS kge
DESTINATION bin
COMPONENT nox
COMPONENT gui)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kge.desktop
DESTINATION share/applications
COMPONENT gui)
install(FILES resources/kge.png
DESTINATION share/${PROJECT_NAME}
COMPONENT gui)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kge.1
DESTINATION share/man/man1
COMPONENT gui)
endif ()
2023-10-11 05:23:12 +00:00
2023-10-11 23:27:03 +00:00
include(cmake/packaging.cmake)