2023-10-09 05:00:50 +00:00
|
|
|
cmake_minimum_required(VERSION 3.22)
|
|
|
|
|
2023-10-11 21:50:35 +00:00
|
|
|
project(kge
|
2023-10-12 02:25:24 +00:00
|
|
|
DESCRIPTION "kyle's editor"
|
|
|
|
LANGUAGES CXX
|
|
|
|
VERSION 0.0.1)
|
2023-10-09 08:27:53 +00:00
|
|
|
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 21:50:35 +00:00
|
|
|
|
2023-10-11 05:23:12 +00:00
|
|
|
string(TIMESTAMP TODAY "%Y%m%d")
|
2023-10-09 05:00:50 +00:00
|
|
|
|
2023-10-11 21:50:35 +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
|
|
|
|
2023-10-12 02:14:10 +00:00
|
|
|
if (CMAKE_HOST_UNIX)
|
2023-10-12 02:25:24 +00:00
|
|
|
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
|
|
|
|
2023-10-12 02:25:24 +00:00
|
|
|
if (${BUILD_GUI})
|
|
|
|
include(cmake/imgui.cmake)
|
|
|
|
endif ()
|
2023-10-11 21:50:35 +00:00
|
|
|
|
|
|
|
#####################
|
|
|
|
### BUILD TARGETS ###
|
|
|
|
#####################
|
|
|
|
|
|
|
|
set(HEADER_FILES
|
2023-10-12 02:25:24 +00:00
|
|
|
Defs.h
|
|
|
|
Buffer.h
|
|
|
|
File.h
|
|
|
|
Cursor.h
|
2023-10-15 06:28:43 +00:00
|
|
|
Frame.h
|
2023-10-11 21:50:35 +00:00
|
|
|
)
|
|
|
|
set(SOURCE_FILES
|
2023-10-12 02:25:24 +00:00
|
|
|
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
|
|
|
)
|
2023-10-11 21:50:35 +00:00
|
|
|
|
|
|
|
add_executable(ke main.cc ${SOURCE_FILES} ${HEADER_FILES})
|
2023-10-11 05:23:12 +00:00
|
|
|
|
2023-10-12 02:25:24 +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 ()
|
2023-10-11 21:50:35 +00:00
|
|
|
|
|
|
|
#######################
|
|
|
|
### INSTALL TARGETS ###
|
|
|
|
#######################
|
|
|
|
|
|
|
|
install(TARGETS ke
|
2023-10-12 02:25:24 +00:00
|
|
|
DESTINATION bin
|
|
|
|
COMPONENT nox)
|
2023-10-11 21:50:35 +00:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ke.1
|
2023-10-12 02:25:24 +00:00
|
|
|
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
|
|
|
|
2023-10-11 22:01:48 +00:00
|
|
|
include(cmake/packaging.cmake)
|