# essim_add_frontend( [LIBS ...]) # # Builds the boilerplate shared by every frontend under src/frontends//: # * a static library essim_ from every .cpp in the current directory # except main.cpp, linking essim_core plus the frontend's own GUI/TUI # toolkit (LIBS); # * the `essim` executable from main.cpp, linking essim_ and the shared, # toolkit-free launcher essim_frontend, emitted at the top of the build tree # (./build/essim) whichever frontend produced it. # # A per-frontend CMakeLists only sets up its toolkit (FetchContent / # find_package, and any directory-scoped include dirs / definitions) and then # calls this with the toolkit's link targets — no target wiring repeated. function(essim_add_frontend name) cmake_parse_arguments(FE "" "" "LIBS" ${ARGN}) set(dir "${CMAKE_CURRENT_SOURCE_DIR}") # Frontend library = every .cpp here except the entry point. file(GLOB FE_SOURCES "${dir}/*.cpp") list(REMOVE_ITEM FE_SOURCES "${dir}/main.cpp") add_library(essim_${name} STATIC ${FE_SOURCES}) target_link_libraries(essim_${name} PUBLIC essim_core ${FE_LIBS}) add_executable(essim "${dir}/main.cpp") target_link_libraries(essim PRIVATE essim_${name} essim_frontend) set_target_properties(essim PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") endfunction()