From 651c8d02cc0b4c0ef7624948892f20aea4ae5aa0 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Thu, 18 Jul 2024 20:39:01 +0300 Subject: [PATCH] CMake: fmt --- CMakeLists.txt | 71 +++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36accf9..97c1b95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,10 @@ cmake_minimum_required(VERSION 3.19) file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW) string(STRIP ${VER_RAW} HYPRLANG_VERSION) -project(hyprlang - VERSION ${HYPRLANG_VERSION} - DESCRIPTION "A library to parse hypr config files" -) +project( + hyprlang + VERSION ${HYPRLANG_VERSION} + DESCRIPTION "A library to parse hypr config files") include(CTest) include(GNUInstallDirs) @@ -18,11 +18,11 @@ set(LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR}) configure_file(hyprlang.pc.in hyprlang.pc @ONLY) if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) - message(STATUS "Configuring hyprlang in Debug") - add_compile_definitions(HYPRLAND_DEBUG) + message(STATUS "Configuring hyprlang in Debug") + add_compile_definitions(HYPRLAND_DEBUG) else() - add_compile_options(-O3) - message(STATUS "Configuring hyprlang in Release") + add_compile_options(-O3) + message(STATUS "Configuring hyprlang in Release") endif() add_compile_definitions(HYPRLANG_INTERNAL) @@ -30,31 +30,30 @@ add_compile_definitions(HYPRLANG_INTERNAL) set(CMAKE_CXX_STANDARD 23) find_package(PkgConfig REQUIRED) -pkg_check_modules(deps REQUIRED IMPORTED_TARGET - hyprutils>=0.1.1 -) +pkg_check_modules(deps REQUIRED IMPORTED_TARGET hyprutils>=0.1.1) file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "include/hyprlang.hpp") add_library(hyprlang SHARED ${SRCFILES}) -target_include_directories( hyprlang - PUBLIC "./include" - PRIVATE "./src" -) -set_target_properties(hyprlang PROPERTIES - VERSION ${HYPRLANG_VERSION} - SOVERSION 2 - PUBLIC_HEADER include/hyprlang.hpp) +target_include_directories( + hyprlang + PUBLIC "./include" + PRIVATE "./src") +set_target_properties( + hyprlang + PROPERTIES VERSION ${HYPRLANG_VERSION} + SOVERSION 2 + PUBLIC_HEADER include/hyprlang.hpp) target_link_libraries(hyprlang PkgConfig::deps) -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # for std::expected. - # probably evil. Arch's clang is very outdated tho... - target_compile_options(hyprlang PUBLIC -std=gnu++2b -D__cpp_concepts=202002L -Wno-macro-redefined) - add_compile_options(-stdlib=libc++) - add_link_options(-stdlib=libc++) - message(STATUS "Using clang++ to compile hyprlang") +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # for std::expected. probably evil. Arch's clang is very outdated tho... + target_compile_options(hyprlang PUBLIC -std=gnu++2b -D__cpp_concepts=202002L + -Wno-macro-redefined) + add_compile_options(-stdlib=libc++) + add_link_options(-stdlib=libc++) + message(STATUS "Using clang++ to compile hyprlang") endif() install(TARGETS hyprlang) @@ -64,16 +63,24 @@ add_custom_target(tests) add_executable(hyprlang_test "tests/parse/main.cpp") target_link_libraries(hyprlang_test PRIVATE hyprlang hyprutils) -add_test(NAME "Parsing" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests COMMAND hyprlang_test "parse") +add_test( + NAME "Parsing" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests + COMMAND hyprlang_test "parse") add_dependencies(tests hyprlang_test) add_executable(hyprlang_fuzz "tests/fuzz/main.cpp") target_link_libraries(hyprlang_fuzz PRIVATE hyprlang hyprutils) -add_test(NAME "Fuzz" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests COMMAND hyprlang_fuzz "fuzz") +add_test( + NAME "Fuzz" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests + COMMAND hyprlang_fuzz "fuzz") add_dependencies(tests hyprlang_fuzz) # Installation -install(TARGETS hyprlang - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) -install(FILES ${CMAKE_BINARY_DIR}/hyprlang.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install( + TARGETS hyprlang + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(FILES ${CMAKE_BINARY_DIR}/hyprlang.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)