summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt138
1 files changed, 138 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..d9d99ba
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,138 @@
+cmake_minimum_required(
+ VERSION
+ 3.20
+)
+project(
+ u8c
+ VERSION
+ 27
+ DESCRIPTION
+ "Unicode manipulation library."
+ HOMEPAGE_URL
+ "https://mandelbrot.dk/delta/u8c"
+ LANGUAGES
+ CXX
+)
+set(
+ CMAKE_CXX_STANDARD
+ 23
+)
+set(
+ CMAKE_CXX_EXTENSIONS
+ OFF
+)
+
+# Options:
+option(
+ U8C_TEST
+ "Build test program."
+ OFF
+)
+
+# 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(
+ "-Wfatal-errors"
+ "-Wall"
+ "-Werror"
+ "-Wextra"
+ "-Wno-attributes"
+ "-pedantic-errors"
+ )
+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(
+ "${PROJECT_SOURCE_DIR}/u8c/include"
+)
+
+# u8c settings:
+add_library(
+ u8c
+ SHARED
+ "u8c/src/operator.cc"
+ "u8c/src/u8c/fmt.cc"
+ "u8c/src/u8c/print.cc"
+ "u8c/src/u8c/println.cc"
+)
+
+# Test settings:
+if(
+ U8C_TEST
+)
+ add_executable(
+ test
+ "u8c-check/src/test.cc"
+ )
+ add_dependencies(
+ test
+ u8c
+ )
+ target_link_libraries(
+ test
+ u8c
+ )
+endif()