alec

Abstraction Layer for Escape Codes
git clone git://git.dimitrijedobrota.com/alec.git
Log | Files | Refs | README | LICENSE

CMakeLists.txt (1570B)


      1 set(PARSER_DIR "${CMAKE_CURRENT_BINARY_DIR}")
      2 
      3 find_package(FLEX)
      4 find_package(BISON)
      5 
      6 set(LEXER_OUT "${PARSER_DIR}/lexer.c")
      7 set(PARSER_OUT "${PARSER_DIR}/parser.c")
      8 
      9 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
     10 	set(FLAGS "--debug")
     11 endif()
     12 
     13 FLEX_TARGET(LEXER lexer.l "${LEXER_OUT}" DEFINES_FILE "${PARSER_DIR}/scanner.h" COMPILE_FLAGS "${FLAGS}")
     14 BISON_TARGET(PARSER parser.y "${PARSER_OUT}" DEFINES_FILE "${PARSER_DIR}/parser.h" COMPILE_FLAGS "${FLAGS}")
     15 ADD_FLEX_BISON_DEPENDENCY(LEXER PARSER)
     16 
     17 add_executable(generator "${LEXER_OUT}" "${PARSER_OUT}" generator.c)
     18 target_include_directories(generator PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
     19 
     20 set(GENERATE_OUT "${CMAKE_BINARY_DIR}/bin")
     21 
     22 set_target_properties(generator PROPERTIES
     23     VERSION ${PROJECT_VERSION}
     24     SOVERSION ${PROJECT_VERSION_MAJOR}
     25     RUNTIME_OUTPUT_DIRECTORY "${GENERATE_OUT}"
     26 )
     27 
     28 set(RULES_NAME "alec.rules.hpp")
     29 set(RULES_FILE "${CMAKE_BINARY_DIR}/${RULES_NAME}")
     30 
     31 configure_file(alec.rules.hpp ${RULES_FILE} COPYONLY)
     32 
     33 add_custom_command(
     34     OUTPUT ${GENERATE_OUT}/alec.hpp
     35     COMMAND generator ${RULES_FILE} > ${GENERATE_OUT}/alec.hpp
     36     DEPENDS generator ${RULES_NAME}
     37     COMMENT "Generating include file"
     38 )
     39 
     40 add_library(alec INTERFACE ${GENERATE_OUT}/alec.hpp)
     41 target_include_directories(alec INTERFACE ${GENERATE_OUT})
     42 
     43 set_target_properties(alec PROPERTIES
     44     VERSION ${PROJECT_VERSION}
     45     SOVERSION ${PROJECT_VERSION_MAJOR}
     46     PUBLIC_HEADER ${GENERATE_OUT}/alec.hpp
     47 )
     48 
     49 install(TARGETS alec
     50     LIBRARY DESTINATION lib
     51     PUBLIC_HEADER DESTINATION include
     52 )