Skip to content

Commit

Permalink
Getting rid of old main functions and adding auto generating main fil…
Browse files Browse the repository at this point in the history
…e feature
  • Loading branch information
grf14003 committed Feb 12, 2020
1 parent c2eee1e commit 4dbd738
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions breadcrumbs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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)

Expand Down Expand Up @@ -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")
Expand All @@ -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})
Expand Down
File renamed without changes.

0 comments on commit 4dbd738

Please sign in to comment.