Skip to content

Commit

Permalink
Merge pull request #157 from project8/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pslocum authored Aug 5, 2020
2 parents df6226d + e50960f commit 9257931
Show file tree
Hide file tree
Showing 114 changed files with 2,396 additions and 10,345 deletions.
219 changes: 107 additions & 112 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ cmake_minimum_required( VERSION 3.1 )

# Define the project
cmake_policy( SET CMP0048 NEW ) # version in project()
project( locust_mc VERSION 1.16.1)
project( locust_mc VERSION 2.0.0)

list( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/Scarab/cmake )
include( PackageBuilder )

pbuilder_prepare_project()


set_option( USE_CPP11 TRUE )

option( locust_mc_BUILD_WITH_KASSIOPEIA "Option to build with Kassiopeia" FALSE )
Expand All @@ -22,19 +21,6 @@ option( locust_mc_BUILD_WITH_ROOT "Option to build with ROOT" TRUE )
# make the data install directory available as a preprocessor macro
add_definitions( -DPB_DATA_INSTALL_DIR=${DATA_INSTALL_DIR} )


#####################
# locust submodules #
#####################


pbuilder_add_submodule( Scarab Scarab/library )

pbuilder_add_submodule( Monarch monarch )
# we need the definitions for HAS_ATTR_IFC and HAS_GRP_IFC from Monarch to use the proper class interfaces in M3Header and M3Stream
set_property( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS ${Monarch_COMPILE_DEFINITIONS} )

# set this up before the Kassiopeia build, so that the Kassiopeia build can use Locust include directories
set (LOCUST_MC_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/Source/Generators/
${CMAKE_CURRENT_SOURCE_DIR}/Source/Transmitters/
Expand All @@ -43,91 +29,73 @@ set (LOCUST_MC_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/Source/Core/
${CMAKE_CURRENT_SOURCE_DIR}/Source/IO/
${CMAKE_CURRENT_SOURCE_DIR}/Source/Distributions/
${CMAKE_CURRENT_SOURCE_DIR}/Source/Kassiopeia/
)

#if (locust_mc_BUILD_WITH_ROOT)
# set( LOCUST_MC_INCLUDE_DIRECTORIES ${LOCUST_MC_INCUDE_DIRECTORIES}
# ${CMAKE_CURRENT_SOURCE_DIR}/Source/IO/
# )
#endif (locust_mc_BUILD_WITH_ROOT)

if (locust_mc_BUILD_WITH_KASSIOPEIA)

include_directories( BEFORE ${LOCUST_MC_INCLUDE_DIRECTORIES} )
# Kassiopeia needs to be built independently from, but as a submodule and dependency of, Locust.
# In other words, the configuration and build environments need to be kept separate.
# However, Locust needs to build against Kassiopeia.
# When Kassiopeia is run from within Locust it knows about the Kassiopeia-derived Locust classes.

# First we run the configure stage of Kassiopeia during the configure (cmake) process of Locust.
# This build takes place in its own build directory, but it installs in the same place as Locust.
# We run cmake twice so that we get all of the variables setup correctly.
# We do this here instead of below in the ExternalProject so that Locust can learn about the Kassiopeia targets at the configure stage.
execute_process(
COMMAND mkdir kassiopeia
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
execute_process(
COMMAND cmake -D CMAKE_INSTALL_PREFIX:STRING=${CMAKE_INSTALL_PREFIX}
-D CMAKE_INSTALL_LIBDIR:STRING=lib
-D BUILD_KASSIOPEIA:BOOL=TRUE
-D BUILD_KEMFIELD:BOOL=TRUE
-D BUILD_KGEOBAG:BOOL=TRUE
-D BUILD_KOMMON:BOOL=TRUE
${PROJECT_SOURCE_DIR}/kassiopeia
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/kassiopeia
)
#execute_process(
# COMMAND cmake -D CMAKE_INSTALL_PREFIX:STRING=${CMAKE_INSTALL_PREFIX} -D BUILD_KASSIOPEIA:BOOL=TRUE -D BUILD_KEMFIELD:BOOL=TRUE -D BUILD_KGEOBAG:BOOL=TRUE -D BUILD_KOMMON:BOOL=TRUE ${PROJECT_SOURCE_DIR}/kassiopeia
# WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/kassiopeia
#)

# Second we use the ExternalProject module to build and install Kassiopeia.
# This takes place during the build phase of Locust.
# Note that we disable the configure stage of the ExternalProject because we already took care of the configure stage above.
include(ExternalProject)

ExternalProject_Add( KassiopeiaExt
PREFIX ${CMAKE_INSTALL_PREFIX}
SOURCE_DIR ${PROJECT_SOURCE_DIR}/kassiopeia
BINARY_DIR ${PROJECT_BINARY_DIR}/kassiopeia
CONFIGURE_COMMAND ""
BUILD_ALWAYS 1
BUILD_COMMAND make
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
INSTALL_COMMAND make -j3 install
)

# Finally we use find_package() to learn about the Kassiopeia build targets.
find_package( Kommon REQUIRED CONFIG HINTS ${PROJECT_BINARY_DIR}/kassiopeia/Kommon )
find_package( KGeoBag REQUIRED CONFIG HINTS ${PROJECT_BINARY_DIR}/kassiopeia/KGeoBag )
find_package( KEMField REQUIRED CONFIG HINTS ${PROJECT_BINARY_DIR}/kassiopeia/KEMField )
find_package( Kassiopeia REQUIRED CONFIG HINTS ${PROJECT_BINARY_DIR}/kassiopeia/Kassiopeia )

if (locust_mc_BUILD_WITH_KASSIOPEIA)
endif (locust_mc_BUILD_WITH_KASSIOPEIA)

# Keep KasperDefaults from overriding the install prefix
set( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE )

list( APPEND CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/kassiopeia/Kommon/cmake
)
include( KasperDefaults )
set( Kommon_DIR ${PROJECT_BINARY_DIR}/kassiopeia/Kommon )
set( KGeoBag_DIR ${PROJECT_BINARY_DIR}/kassiopeia/KGeoBag )
set( KEMField_DIR ${PROJECT_BINARY_DIR}/kassiopeia/KEMField )
#####################
# locust submodules #
#####################

set( CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)
set( DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/data )
pbuilder_add_submodule( Scarab Scarab/library )

add_subdirectory( kassiopeia )

if( Kommon_ENABLE_DEBUG )
add_definitions( -DKommon_ENABLE_DEBUG )
endif( Kommon_ENABLE_DEBUG )
if( Kommon_USE_VTK )
add_definitions( -DKommon_ENABLE_DEBUG )
endif( Kommon_USE_VTK )
if( Kommon_USE_ROOT )
add_definitions( -DKommon_USE_ROOT )
endif( Kommon_USE_ROOT )

if( KGeoBag_ENABLE_DEBUG )
add_definitions( -DKGeoBag_ENABLE_DEBUG )
endif( KGeoBag_ENABLE_DEBUG )
if( KGeoBag_USE_ROOT )
add_definitions( -DKGeoBag_USE_ROOT )
endif( KGeoBag_USE_ROOT )
if( KGeoBag_USE_VTK )
add_definitions( -DKGeoBag_USE_VTK )
endif( KGeoBag_USE_VTK )

if( KEMField_USE_ROOT )
add_definitions( -DKEMField_USE_ROOT )
endif( KEMField_USE_ROOT )
if( KEMField_USE_VTK )
add_definitions( -DKEMField_USE_VTK )
endif( KEMField_USE_VTK )

if( Kassiopeia_ENABLE_DEBUG )
add_definitions( -DKassiopeia_ENABLE_DEBUG )
endif( Kassiopeia_ENABLE_DEBUG )
if( Kassiopeia_USE_ROOT )
add_definitions( -DKassiopeia_USE_ROOT )
endif( Kassiopeia_USE_ROOT )
if( Kassiopeia_USE_VTK )
add_definitions( -DKassiopeia_USE_VTK )
endif( Kassiopeia_USE_VTK )

include( ${PROJECT_BINARY_DIR}/kassiopeia/Kommon/KommonConfig.cmake )
include_directories( ${Kommon_INCLUDE_DIRS} )
pbuilder_add_ext_libraries( ${Kommon_LIBRARIES} )

include( ${PROJECT_BINARY_DIR}/kassiopeia/KGeoBag/KGeoBagConfig.cmake )
include_directories( ${KGeoBag_INCLUDE_DIRS} )
pbuilder_add_ext_libraries( ${KGeoBag_LIBRARIES} )

include( ${PROJECT_BINARY_DIR}/kassiopeia/KEMField/KEMFieldConfig.cmake )
include_directories( ${KEMField_INCLUDE_DIRS} )
pbuilder_add_ext_libraries( ${KEMField_LIBRARIES} )

include( ${PROJECT_BINARY_DIR}/kassiopeia/Kassiopeia/KassiopeiaConfig.cmake )
include_directories( ${Kassiopeia_INCLUDE_DIRS} )
pbuilder_add_ext_libraries( ${Kassiopeia_LIBRARIES} )
endif (locust_mc_BUILD_WITH_KASSIOPEIA)
pbuilder_add_submodule( Monarch monarch )
# we need the definitions for HAS_ATTR_IFC and HAS_GRP_IFC from Monarch to use the proper class interfaces in M3Header and M3Stream
set_property( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} APPEND PROPERTY COMPILE_DEFINITIONS ${Monarch_COMPILE_DEFINITIONS} )


#######################
Expand All @@ -141,6 +109,7 @@ else (GSL_FOUND)
message(FATAL "GSL not found")
endif (GSL_FOUND)


# FFTW
find_package(FFTW REQUIRED)
if (NOT FFTW_THREADS_FOUND)
Expand Down Expand Up @@ -170,42 +139,68 @@ endif (ROOT_FOUND)
include_directories (${ROOT_INCLUDE_DIR})


###########
# library #
###########

if( locust_mc_BUILD_WITH_KASSIOPEIA )
# Here we add the include directories, link directories, and libraries that will be used by Kassiopeia to Locust's build configuration.

set (LOCUST_MC_INCLUDE_DIRECTORIES
${LOCUST_MC_INCLUDE_DIRECTORIES}
${CMAKE_CURRENT_SOURCE_DIR}/Source/Kassiopeia/
${Kommon_INCLUDE_DIRS}
${KGeoBag_INCLUDE_DIRS}
${KEMField_INCLUDE_DIRS}
${Kassiopeia_INCLUDE_DIRS}
)

set (LOCUST_MC_LINK_DIRECTORIES
${LOCUST_MC_LINK_DIRECTORIES}
${LIB_INSTALL_DIR}
)

###########
# library #
###########
# We need to have the LocustMC library depend on the Kassiopeia libraries, and to the KassiopeiaExt target
# To do this we create an imported library for each Kassiopeia library
# We then add a dependency of KassiopeiaExt to each imported library target
# LocustMC library will link to those imported libraries, and therefore depend on KassiopeiaExt

set( All_Kassiopeia_LIBRARIES ${Kommon_LIBRARIES} ${KGeoBag_LIBRARIES} ${KEMField_LIBRARIES} ${Kassiopeia_LIBRARIES} )
foreach( LIBRARY IN LISTS All_Kassiopeia_LIBRARIES )
add_library( ${LIBRARY} SHARED IMPORTED )
#message( STATUS "****** constructed name: ${LIB_INSTALL_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}${LIBRARY}${CMAKE_SHARED_LIBRARY_SUFFIX}" )
set_target_properties( ${LIBRARY} PROPERTIES IMPORTED_LOCATION "${LIB_INSTALL_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}${LIBRARY}${CMAKE_SHARED_LIBRARY_SUFFIX}" )
add_dependencies( ${LIBRARY} KassiopeiaExt )
endforeach()


pbuilder_add_ext_libraries(
${Kommon_LIBRARIES}
${KGeoBag_LIBRARIES}
${KEMField_LIBRARIES}
${Kassiopeia_LIBRARIES}
)

add_subdirectory( Source )
add_subdirectory( Data )
endif( locust_mc_BUILD_WITH_KASSIOPEIA )

include_directories( ${LOCUST_MC_INCLUDE_DIRECTORIES} )
link_directories( ${LOCUST_MC_LINK_DIRECTORIES} )

add_subdirectory( Source )
add_subdirectory( Data )
add_subdirectory( Data/TransferFunctions )

###############
# executables #
###############

if (locust_mc_ENABLE_EXECUTABLES )
add_subdirectory( Source/Applications )
endif (locust_mc_ENABLE_EXECUTABLES )

################
# Config files #
################





#pbuilder_install_headers(${CMAKE_CURRENT_SOURCE_DIR}/Source/ReceiverTransferFunctions.hh)

#add_executable( generate_data ${CMAKE_CURRENT_SOURCE_DIR}/Source/generate_data.cc ${CMAKE_CURRENT_SOURCE_DIR}/Source/ReceiverTransferFunctions.cc )
#target_link_libraries( generate_data ${EXTERNAL_LIBRARIES} )
#pbuilder_install_executables( generate_data )

#add_executable( check_egg_digitization ${CMAKE_CURRENT_SOURCE_DIR}/Source/check_egg_digitization.cc )
#target_link_libraries( check_egg_digitization ${EXTERNAL_LIBRARIES} )
#pbuilder_install_executables( check_egg_digitization )

pbuilder_install_config (

)
add_subdirectory( Config )

37 changes: 37 additions & 0 deletions Config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# CMakeLists.txt for locust_mc/Config
# Author: N.S. Oblath

configure_file( JustKass.xml.in JustKass.xml )
configure_file( JustKassFieldMap.xml.in JustKassFieldMap.xml )
configure_file( LocustKass_Waveguide_Template.xml.in LocustKass_Waveguide_Template.xml )
configure_file( LocustKass_FreeSpace_Template.xml.in LocustKass_FreeSpace_Template.xml )
configure_file( LocustWaveguideTemplate.json.in LocustWaveguideTemplate.json )
configure_file( LocustFreeSpaceTemplate.json.in LocustFreeSpaceTemplate.json )
configure_file( LocustPlaneWaveTemplate.json.in LocustPlaneWaveTemplate.json )
configure_file( LocustFakeTrack.json.in LocustFakeTrack.json )
configure_file( LocustMagDipoleAntennaTemplate.json.in LocustMagDipoleAntennaTemplate.json )
configure_file( LocustTestSignal.json.in LocustTestSignal.json )
configure_file( plotfieldmap.c.in plotfieldmap.c )
configure_file( katydid.json.in katydid.json )
configure_file( ChannelAggregatorConfig.yaml.in ChannelAggregatorConfig.yaml )


set (EXAMPLE_CONFIGFILES
${CMAKE_CURRENT_BINARY_DIR}/JustKass.xml
${CMAKE_CURRENT_BINARY_DIR}/JustKassFieldMap.xml
${CMAKE_CURRENT_BINARY_DIR}/LocustKass_Waveguide_Template.xml
${CMAKE_CURRENT_BINARY_DIR}/LocustKass_FreeSpace_Template.xml
WaveguideGeometry.xml
FreeSpaceGeometry.xml
${CMAKE_CURRENT_BINARY_DIR}/LocustWaveguideTemplate.json
${CMAKE_CURRENT_BINARY_DIR}/LocustFreeSpaceTemplate.json
${CMAKE_CURRENT_BINARY_DIR}/LocustPlaneWaveTemplate.json
${CMAKE_CURRENT_BINARY_DIR}/LocustFakeTrack.json
${CMAKE_CURRENT_BINARY_DIR}/LocustMagDipoleAntennaTemplate.json
${CMAKE_CURRENT_BINARY_DIR}/LocustTestSignal.json
${CMAKE_CURRENT_BINARY_DIR}/katydid.json
${CMAKE_CURRENT_BINARY_DIR}/ChannelAggregatorConfig.yaml
${CMAKE_CURRENT_BINARY_DIR}/plotfieldmap.c
)

pbuilder_install_config (${EXAMPLE_CONFIGFILES})
Loading

0 comments on commit 9257931

Please sign in to comment.