From 4dbd738e62f161dce9891eb20e301292396d4210 Mon Sep 17 00:00:00 2001 From: Greg Foss Date: Wed, 12 Feb 2020 15:55:57 -0500 Subject: [PATCH] Getting rid of old main functions and adding auto generating main file feature --- breadcrumbs/CMakeLists.txt | 35 ++++++++++++++----- .../gen/AlgoBreadcrumbs.cpp} | 0 .../gen/VirtualOutputIOProcessor.cpp} | 0 3 files changed, 26 insertions(+), 9 deletions(-) rename breadcrumbs/{src/main/Breadcrumbs.cpp => breadcrumbs/gen/AlgoBreadcrumbs.cpp} (100%) rename breadcrumbs/{src/main/VirtualOutputProcessor.cpp => breadcrumbs/gen/VirtualOutputIOProcessor.cpp} (100%) diff --git a/breadcrumbs/CMakeLists.txt b/breadcrumbs/CMakeLists.txt index efed5d9..e3f4a0d 100644 --- a/breadcrumbs/CMakeLists.txt +++ b/breadcrumbs/CMakeLists.txt @@ -1,8 +1,3 @@ -# This file controls the build process. When you save it, VS figures out what types of executables that it builds. -# Then, you can switch the executable that you want to run at the top from the drop down and hit run to build and -# run it. -# - cmake_minimum_required (VERSION 2.6) message("Starting CMAKE") @@ -20,6 +15,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) # Compiled executa set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib) # Compiled libraries (.lib and .dll) set(CMAKE_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/include) # Publicly accessible header files set(IMPL_ALGO_PATH ${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/algos) # BFS Implemenation algo source file path + set(IMPL_IO_PROCS_PATH ${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/io_procs) set(IMPL_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/include) @@ -59,6 +55,26 @@ include_directories("${CMAKE_SOURCE_DIR}") # Adding implementation include include_directories("${IMPL_INCLUDE_PATH}") +set(Bfs_TEMP_ALGORITHM_CLIENT_LIMIT 1) +file(MAKE_DIRECTORY ${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/gen) + +file(GLOB ALGOS_EXECS CONFIGURE_DEPENDS "${IMPL_ALGO_PATH}/*.cpp") +foreach(X IN LISTS ALGOS_EXECS) + get_filename_component(N ${X} NAME_WE) + set(Bfs_TEMP_ALGORITHM_NAME ${N}) + message("Generating Algorithm main(): ${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/gen/${N}.cpp") + configure_file("${CMAKE_SOURCE_DIR}/template/AlgorithmTemplate.cpp.in" ${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/gen/${N}.cpp) +endforeach() + +file(GLOB IO_PROC_EXECS CONFIGURE_DEPENDS "${IMPL_IO_PROCS_PATH}/*.cpp") +foreach(X IN LISTS IO_PROC_EXECS) + get_filename_component(N ${X} NAME_WE) + set(Bfs_TEMP_IOPROC_NAME ${N}) + message("Generating IO Processor main(): ${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/gen/${N}.cpp") + configure_file("${CMAKE_SOURCE_DIR}/template/IOProcessorTemplate.cpp.in" ${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/gen/${N}.cpp) +endforeach() +message("") + # puts all .cpp files inside src to the SOURCES variable # TODO: replace this with a script for collecting cpp files file(GLOB_RECURSE ALGOS CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/algos/*.cpp") @@ -67,16 +83,17 @@ file(GLOB_RECURSE COMMS CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/comms/*.cpp") file(GLOB_RECURSE CONFIG CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/config/*.cpp") file(GLOB_RECURSE LOGGING CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/logging/*.cpp") -# Temp -file(GLOB EXECS CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/main/*.cpp") - # Compiling BFS implementation source files file(GLOB_RECURSE IMPL_SRC CONFIGURE_DEPENDS "${ROOT_FOLDER_DIRNAME}/*.cpp") +list(FILTER IMPL_SRC EXCLUDE REGEX "${ROOT_FOLDER_DIRNAME}/gen/*") + +# Getting template output files to create executables +file(GLOB ALL_EXECS CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/gen/*.cpp") # Adding executables # This is fine for now, but we may want to switch to a more manual versio so we can # configure which files are included in which exe's -foreach(X IN LISTS EXECS) +foreach(X IN LISTS ALL_EXECS) get_filename_component(N ${X} NAME_WE) message(STATUS "Generating Executable: ${N}.exe Main File: ${X}"}) add_executable(${N} ${IMPL_SRC} ${X} ${ALGOS} ${IO_PROCS} ${COMMS} ${CONFIG} ${LOGGING}) diff --git a/breadcrumbs/src/main/Breadcrumbs.cpp b/breadcrumbs/breadcrumbs/gen/AlgoBreadcrumbs.cpp similarity index 100% rename from breadcrumbs/src/main/Breadcrumbs.cpp rename to breadcrumbs/breadcrumbs/gen/AlgoBreadcrumbs.cpp diff --git a/breadcrumbs/src/main/VirtualOutputProcessor.cpp b/breadcrumbs/breadcrumbs/gen/VirtualOutputIOProcessor.cpp similarity index 100% rename from breadcrumbs/src/main/VirtualOutputProcessor.cpp rename to breadcrumbs/breadcrumbs/gen/VirtualOutputIOProcessor.cpp