Skip to content

Instantly share code, notes, and snippets.

@michaeltryby
Last active June 30, 2021 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeltryby/7f81058ab25d581328510209d3e9da78 to your computer and use it in GitHub Desktop.
Save michaeltryby/7f81058ab25d581328510209d3e9da78 to your computer and use it in GitHub Desktop.
Builds SWMM CLE
#
# CMakeLists.txt - CMake configuration file for old swmm-solver releases
#
# Created: June 4, 2020
# Updated: June 30, 2021
#
# Author: Michael E. Tryby
# US EPA ORD/CESER
#
# Build Information:
# SWMM Compiler
# v5.1.14 Visual Studio 15 2017
# ...
# v5.1.12 Visual Studio 10 2010
# ...
#
remove_definitions(-DDLL)
add_executable(runswmm
${SWMM_SOURCES}
)
target_compile_definitions(runswmm
PUBLIC
CLE
)
target_compile_options(runswmm
PUBLIC
"$<$<C_COMPILER_ID:MSVC>:"
"$<$<CONFIG:Release>:/GL>"
"$<$<CONFIG:Release>:/fp:fast>"
"$<$<CONFIG:Release>:/Zi>"
">"
)
target_link_options(runswmm
PUBLIC
"$<$<C_COMPILER_ID:MSVC>:"
"$<$<CONFIG:Release>:/LTCG>"
">"
)
target_include_directories(runswmm
PUBLIC
${PROJECT_SOURCE_DIR}/src
)
#
# CMakeLists.txt - CMake configuration file for old swmm-solver/src releases
#
# Created: Jun 30, 2021
# Updated:
#
# Author: Michael E. Tryby
# US EPA ORD/CESER
#
find_package(OpenMP)
file(GLOB
SWMM_SOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c *.h
)
########## Library Target ##########
if(BUILD_DEF)
# Build library with def file interface for backward compatibility
set_source_files_properties(swmm5.def
PROPERTIES_HEADER_FILE_ONLY TRUE
)
add_library(swmm5
SHARED
${SWMM_SOURCES}
swmm5.def
)
else()
add_library(swmm5
SHARED
${SWMM_SOURCES}
)
endif()
target_compile_definitions(swmm5
PUBLIC
DLL
)
target_compile_options(swmm5
PUBLIC
$<$<C_COMPILER_ID:MSVC>:
$<$<CONFIG:Release>:/GL>
$<$<CONFIG:Release>:/fp:fast>
$<$<CONFIG:Release>:/Zi>
>
)
target_link_options(swmm5
PUBLIC
$<$<C_COMPILER_ID:MSVC>:
$<$<CONFIG:Release>:/LTCG:incremental>
>
)
target_link_libraries(swmm5
PUBLIC
$<$<NOT:$<BOOL:$<C_COMPILER_ID:MSVC>>>:m>
$<$<BOOL:OpenMP_C_FOUND>:OpenMP::OpenMP_C>
)
target_include_directories(swmm5
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${INCLUDE_DIST}>
)
install(TARGETS swmm5 EXPORT swmm5Targets
RUNTIME DESTINATION "${TOOL_DIST}"
LIBRARY DESTINATION "${TOOL_DIST}"
ARCHIVE DESTINATION "${LIBRARY_DIST}"
FRAMEWORK DESTINATION "${TOOL_DIST}"
)
# Create target import scripts so other cmake projects can use swmm libraries
install(
EXPORT
swmm5Targets
DESTINATION
${CONFIG_DIST}
FILE
swmm5-config.cmake
)
install(
FILES
swmm5.h
DESTINATION
${INCLUDE_DIST}
)
########## CLE Target ##########
remove_definitions(-DDLL)
add_executable(runswmm
${SWMM_SOURCES}
)
target_compile_definitions(runswmm
PUBLIC
CLE
)
target_compile_options(runswmm
PUBLIC
$<$<C_COMPILER_ID:MSVC>:
$<$<CONFIG:Release>:/GL>
$<$<CONFIG:Release>:/fp:fast>
$<$<CONFIG:Release>:/Zi>
>
)
target_link_options(runswmm
PUBLIC
$<$<C_COMPILER_ID:MSVC>:
$<$<CONFIG:Release>:/LTCG>
>
)
target_include_directories(runswmm
PUBLIC
${PROJECT_SOURCE_DIR}/src
)
install(TARGETS runswmm
DESTINATION ${TOOL_DIST}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment