blob: 794bb0c43c62e8ca50ae9734e080e6d316fa74b3 (
plain) (
tree)
|
|
cmake_minimum_required(
VERSION
3.20
)
project(
dux
VERSION
29
DESCRIPTION
"General purpose library."
HOMEPAGE_URL
"https://mandelbrot.dk/delta/dux"
LANGUAGES
CXX
)
set(
CMAKE_CXX_STANDARD
23
)
# Options:
option(
DUX_ENABLE_DEMO
"Build the demo program."
)
option(
DUX_ENABLE_SYS
"Enable the system extensions."
)
option(
DUX_GFXPROTO
"Set the graphics protocol: \"windx\" (WinAPI/DirectX), \"wlgl\" (Wayland/OpenGL), \"wlvk\" (Wayland/Vulkan), \"xgl\" (X/OpenGL), \"xvk\" (X/Vulkan)"
)
option(
DUX_SFXPROTO
"Set the sound protocol: \"dx\" (DirectX), \"pa\" (PulseAudio), \"pw\" (PipeWire)"
)
# Disable in-souce builds:
if(
"${PROJECT_BINARY_DIR}"
STREQUAL
"${PROJECT_SOURCE_DIR}"
)
message(
FATAL_ERROR
"In-source building is not allowed."
)
endif()
# Compiler Settings:
message(
STATUS
"Enabling colour output for Clang or GCC..."
)
if(
"${CMAKE_CXX_COMPILER_ID}"
STREQUAL
"Clang"
)
add_compile_options(
"-fcolor-diagnostics"
)
elseif(
"${CMAKE_CXX_COMPILER_ID}"
STREQUAL
"GNU"
)
add_compile_options (
"-fdiagnostics-color=always"
)
endif()
message(
STATUS
"Enabling compile warnings..."
)
if(
MSVC
)
add_compile_options(
"/W4"
"/WX"
)
else()
add_compile_options(
"-pedantic-errors"
"-Wfatal-errors"
"-Wall"
"-Wconversion"
"-Werror"
"-Wextra"
"-Wunreachable-code"
"-Wunused"
)
if(
"${CMAKE_CXX_COMPILER_ID}"
STREQUAL
"Clang"
)
add_compile_options(
"-Wnewline-eof"
)
endif()
endif()
if(
CMAKE_BUILD_TYPE
MATCHES
Release
)
message(
STATUS
"Setting optimisation level..."
)
if(
MSVC
)
add_compile_options(
"/Os"
)
else()
add_compile_options(
"-Os"
)
endif()
endif()
# Include directories:
include_directories(
"${PROJECT_SOURCE_DIR}/include"
)
# dux settings:
add_library(
dux
SHARED
"src/dux/_setsiginthandl.cc"
"src/dux/_siginthandl.cc"
"src/dux/_sigtocsig.cc"
"src/dux/abrt.cc"
"src/dux/endgfx.cc"
"src/dux/exit.cc"
"src/dux/getenv.cc"
"src/dux/goatmaster.cc"
"src/dux/initgfx.cc"
"src/dux/qexit.cc"
"src/dux/raise.cc"
"src/dux/sighandl.cc"
"src/dux/sleep.cc"
"src/dux/trap.cc"
"src/dux/unreach.cc"
"src/dux/win.cc"
)
if(
UNIX
)
set_property(
TARGET
dux
APPEND
PROPERTY
SOURCES
"src/dux/_freepthrdhandl.cc"
"src/dux/_getpthrdhandl.cc"
"src/dux/_pthrdcrt.cc"
"src/dux/_pthrdjoin.cc"
)
endif()
target_compile_definitions(
dux
PRIVATE
_XOPEN_SOURCE=700
)
if(
DUX_GFXPROTO
STREQUAL
"wlgl"
)
message(
STATUS
"Using Wayland/OpenGL for graphics."
)
target_compile_definitions(
dux
PRIVATE
dux_gfxproto_wlgl
)
elseif(
DUX_GFXPROTO
STREQUAL
"wlvk"
)
message(
STATUS
"Using Wayland/Vulkan for graphics."
)
target_compile_definitions(
dux
PRIVATE
dux_gfxproto_wlvk
)
elseif(
DUX_GFXPROTO
STREQUAL
"xgl"
)
message(
STATUS
"Using X/OpenGL for graphics."
)
target_compile_definitions(
dux
PRIVATE
dux_gfxproto_xgl
)
elseif(
DUX_GFXPROTO
STREQUAL
"xvk"
)
message(
STATUS
"Using X/Vulkan for graphics."
)
target_compile_definitions(
dux
PRIVATE
dux_gfxproto_xvk
)
else()
message(
FATAL_ERROR
"Graphics system undefined (or invalid)! Set option \"DUX_GFXPROTO\" to: \"wlgl\" (Wayland/OpenGL), \"wlvk\" (Wayland/Vulkan), \"xgl\" (X/OpenGL), or \"xvk\" (X/Vulkan)!"
)
endif()
if(
DUX_GFXPROTO
STREQUAL
"wlgl"
OR
DUX_GFXPROTO
STREQUAL
"wlvk"
)
target_link_libraries(
dux
wayland-client
)
elseif(
DUX_GFXPROTO
STREQUAL
"xgl"
OR
DUX_GFXPROTO
STREQUAL
"xvk"
)
target_link_libraries(
dux
xcb
)
if(
DUX_GFXPROTO
STREQUAL
"xgl"
)
target_link_libraries(
dux
X11-xcb
)
endif()
endif()
if(
NOT
WIN32
)
target_link_libraries(
dux
dl
pthread
)
endif()
# Demo settings:
if(
DUX_ENABLE_DEMO
)
add_executable(
demo
"dux-demo/main.cc"
)
add_dependencies(
demo
dux
)
target_link_libraries(
demo
dux
)
endif()
|