alecAbstraction Layer for Escape Codes |
git clone git://git.dimitrijedobrota.com/alec.git |
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING | |
CMakeLists.txt (2975B)
1 cmake_minimum_required(VERSION 3.14) 2 3 include(cmake/prelude.cmake) 4 5 project( 6 alec 7 VERSION 0.1.18 8 DESCRIPTION "Abstraction Layer for Escape Codes" 9 HOMEPAGE_URL "git://git.dimitrijedobrota.com/alec.git" 10 LANGUAGES CXX 11 ) 12 13 include(cmake/project-is-top-level.cmake) 14 include(cmake/variables.cmake) 15 16 # ---- Build library ---- 17 18 set(PARSER_DIR "${CMAKE_CURRENT_BINARY_DIR}/source") 19 file(MAKE_DIRECTORY ${PARSER_DIR}) 20 21 find_package(FLEX) 22 find_package(BISON) 23 24 set(LEXER_OUT "${PARSER_DIR}/lexer.cpp") 25 set(PARSER_OUT "${PARSER_DIR}/parser.cpp") 26 27 if(CMAKE_BUILD_TYPE STREQUAL "Debug") 28 set(FLAGS "--debug") 29 endif() 30 31 FLEX_TARGET(LEXER source/lexer.l "${LEXER_OUT}" DEFINES_FILE "${PARSER_DIR}/scanner.hpp" COMPILE_FLAGS "${FLAGS}") 32 BISON_TARGET(PARSER source/parser.y "${PARSER_OUT}" DEFINES_FILE "${PARSER_DIR}/parser.hpp" COMPILE_FLAGS "${FLAGS}") 33 ADD_FLEX_BISON_DEPENDENCY(LEXER PARSER) 34 35 set_source_files_properties(${LEXER_OUT} PROPERTIES SKIP_LINTING ON) 36 set_source_files_properties(${PARSER_OUT} PROPERTIES SKIP_LINTING ON) 37 38 add_executable(generator "${LEXER_OUT}" "${PARSER_OUT}" source/generator.cpp) 39 target_include_directories(generator PRIVATE source ${PARSER_DIR}) 40 41 find_package(cemplate CONFIG REQUIRED) 42 43 target_link_libraries(generator PRIVATE cemplate::cemplate) 44 target_compile_features(generator PUBLIC cxx_std_20) 45 46 47 set(GENERATE_OUT_BIN "${PROJECT_BINARY_DIR}/bin") 48 set(GENERATE_OUT_INCLUDE "${PROJECT_BINARY_DIR}/include/alec") 49 file(MAKE_DIRECTORY ${GENERATE_OUT_BIN} ${GENERATE_OUT_INCLUDE}) 50 51 set_target_properties(generator PROPERTIES 52 VERSION ${PROJECT_VERSION} 53 SOVERSION ${PROJECT_VERSION_MAJOR} 54 RUNTIME_OUTPUT_DIRECTORY "${GENERATE_OUT_BIN}" 55 ) 56 57 set(RULES_NAME "alec.rules.hpp") 58 set(RULES_FILE "${GENERATE_OUT_INCLUDE}/${RULES_NAME}") 59 configure_file(source/alec.rules.hpp ${RULES_FILE} COPYONLY) 60 61 add_custom_command( 62 OUTPUT ${GENERATE_OUT_INCLUDE}/alec.hpp 63 COMMAND generator ${RULES_FILE} > ${GENERATE_OUT_INCLUDE}/alec.hpp 64 DEPENDS generator source/${RULES_NAME} 65 COMMENT "Generating include file" 66 ) 67 68 # ---- Declare library ---- 69 70 add_library(alec_alec INTERFACE ${GENERATE_OUT_INCLUDE}/alec.hpp) 71 add_library(alec::alec ALIAS alec_alec) 72 73 set_property( 74 TARGET alec_alec PROPERTY 75 EXPORT_NAME alec 76 ) 77 78 target_include_directories( 79 alec_alec ${warning_guard} 80 INTERFACE 81 "\$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>" 82 ) 83 84 target_compile_features(alec_alec INTERFACE cxx_std_20) 85 86 # ---- Install rules ---- 87 88 if(NOT CMAKE_SKIP_INSTALL_RULES) 89 include(cmake/install-rules.cmake) 90 endif() 91 92 # ---- Examples ---- 93 94 if(PROJECT_IS_TOP_LEVEL) 95 option(BUILD_EXAMPLES "Build examples tree." "${alec_DEVELOPER_MODE}") 96 if(BUILD_EXAMPLES) 97 add_subdirectory(example) 98 endif() 99 endif() 100 101 # ---- Developer mode ---- 102 103 if(NOT alec_DEVELOPER_MODE) 104 return() 105 elseif(NOT PROJECT_IS_TOP_LEVEL) 106 message( 107 AUTHOR_WARNING 108 "Developer mode is intended for developers of alec" 109 ) 110 endif() 111 112 include(cmake/dev-mode.cmake)