cmake_minimum_required(VERSION 3.5.0)
# set the project name and version
project(StringsTableTest VERSION 1.0)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# add the Program library
add_library(Program program.cpp)
# add the StringsTable library
add_library(StringsTable FixedStrings.cpp FixedStrings.inl)
target_include_directories(StringsTable PUBLIC build)
# add the executable
add_executable(StringsTableTest main.cpp)
target_link_libraries(StringsTableTest PUBLIC Program StringsTable)
# add generator to create the strings table
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/FixedStrings.inl
COMMAND ${CMAKE_CXX_COMPILER} ../main.cpp $<TARGET_FILE:Program> -o dummy 2>&1
| sed -n 's@.\*undefined.\*cFixedStringId_\\\([[:alnum:]_]\*\\\).\*@DEFINE_FIXED_STRING\(\\1\)@p'
| sort | uniq > FixedStrings.inl
DEPENDS Program
)