# CMakeLists.txt for the sexpr_config example TLM. # # This is the TLM template's CMakeLists.txt with the three additions needed to # build an s-expression configuration file parser. They are marked <1> .. <3> # below; everything else is the template unchanged. cmake_minimum_required(VERSION 3.1 FATAL_ERROR) set( TLM sexpr_config ) project( ${TLM} ) set( CPACK_PACKAGE_VERSION_MAJOR 1 ) set( CPACK_PACKAGE_VERSION_MINOR 0 ) set( CPACK_PACKAGE_VERSION_PATCH 0 ) set( CPACK_PACKAGE_CONTACT "Firstname Lastname " ) set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "S-expression configuration file example TLM" ) include(tlm) # <1> Turn sexpr_config.keywords into a lexer. The arguments are the keyword # file, the header to generate, the C++ file to generate, and the namespace to # put the token enum T in. # # The BASENAME of the keyword file decides the name of the generated class: # sexpr_config.keywords -> class SEXPR_CONFIG_LEXER, so choose it as carefully # as you would choose a class name. Keep the namespace short, because every # token is written ::T_ when it needs qualifying. # # Both outputs are written into the build directory, so a fresh checkout never # carries generated code and editing the keyword file re-runs the generator. make_lexer( ${CMAKE_CURRENT_SOURCE_DIR}/sexpr_config.keywords ${CMAKE_CURRENT_BINARY_DIR}/sexpr_config_lexer.h ${CMAKE_CURRENT_BINARY_DIR}/sexpr_config_keywords.cc CFG_T ) # <2> The generated keyword table is a source file of this TLM, and the # generated header is found in the build directory. set( SOURCES sexpr_config.cc ${CMAKE_CURRENT_BINARY_DIR}/sexpr_config_keywords.cc ) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) add_library( ${TLM} SHARED ${SOURCES} ) set_target_properties( ${TLM} PROPERTIES PREFIX "" SUFFIX ".tlm.so" ) # <3> DSNLEXER itself lives in libsexpr.so, so link against it. target_link_libraries( ${TLM} ${LIBSEXPR_LIBRARY} ${LIBSTATE_LOGIC_LIBRARY} rt ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${TLM}.tlm.so DESTINATION /SoftPLC/tlm/ ) # The configuration file ships with the TLM and belongs beside it, which is # where TLM::MakeFilename() looks for it. install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/SEXPRCFG.LST DESTINATION /SoftPLC/tlm/ ) # Declaring it a conffile keeps a site's edited copy from being overwritten # when a newer version of this package is installed. add_conffiles( /SoftPLC/tlm/SEXPRCFG.LST ) include(CPack)