-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cmake-dev' into 'master'
CMake Target-Based Implementation Closes #7 See merge request gridkit/gridkit!12
- Loading branch information
Showing
26 changed files
with
412 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,17 +55,23 @@ | |
# endorsement purposes. | ||
# | ||
|
||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
cmake_minimum_required(VERSION 3.12) | ||
|
||
project(gridkit) | ||
|
||
set(component_models | ||
#generic_model | ||
) | ||
set(PACKAGE_NAME "GRIDKIT") | ||
set(PACKAGE_STRING "GRIDKIT 0.0.6") | ||
set(PACKAGE_TARNAME "gridkit") | ||
|
||
set(PACKAGE_VERSION_MAJOR "1") | ||
set(PACKAGE_VERSION_MINOR "0") | ||
|
||
set(solver_libs | ||
# generic_solver | ||
) | ||
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}") | ||
|
||
# Ipopt support is disabled by default | ||
option(GRIDKIT_ENABLE_IPOPT "Enable Ipopt support" ON) | ||
|
@@ -74,13 +80,32 @@ option(GRIDKIT_ENABLE_IPOPT "Enable Ipopt support" ON) | |
option(GRIDKIT_ENABLE_SUNDIALS "Enable SUNDIALS support" ON) | ||
|
||
# Enable KLU | ||
option(GRIDKIT_ENABLE_SUNDIALS_SPARSE "Enable SUNDIALS sparse linear solvers" OFF) | ||
|
||
option(GRIDKIT_ENABLE_SUNDIALS_SPARSE "Enable SUNDIALS sparse linear solvers" ON) | ||
|
||
set(CMAKE_MACOSX_RPATH 1) | ||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/config) | ||
|
||
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling#always-full-rpath | ||
# use, i.e. don't skip the full RPATH for the build tree | ||
set(CMAKE_SKIP_BUILD_RPATH FALSE) | ||
|
||
# when building, don't use the install RPATH already | ||
# (but later on when installing) | ||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) | ||
|
||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") | ||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/config) | ||
|
||
# add the automatically determined parts of the RPATH | ||
# which point to directories outside the build tree to the install RPATH | ||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
|
||
# the RPATH to be used when installing, but only if it's not a system directory | ||
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) | ||
if("${isSystemDir}" STREQUAL "-1") | ||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") | ||
endif("${isSystemDir}" STREQUAL "-1") | ||
|
||
|
||
# TODO: Probably beter to set a debug interface target | ||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -O0 -g") | ||
|
@@ -89,31 +114,61 @@ set(CMAKE_CXX_STANDARD 11) | |
|
||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
option(BUILD_SHARED_LIBS:BOOL "Build shared libraries" ON) | ||
option(GRIDKIT_BUILD_SHARED "Build shared libraries" ON) | ||
option(GRIDKIT_BUILD_STATIC "Build static libraries" OFF) | ||
|
||
if(GRIDKIT_ENABLE_IPOPT) | ||
include(FindIpopt) | ||
set(CMAKE_INSTALL_RPATH ${IPOPT_LIBRARY_DIR} ${CMAKE_INSTALL_RPATH}) | ||
endif() | ||
|
||
include(FindSUNDIALS) | ||
set(CMAKE_INSTALL_RPATH ${SUNDIALS_LIBRARY_DIR} ${CMAKE_INSTALL_RPATH}) | ||
|
||
if(GRIDKIT_ENABLE_SUNDIALS) | ||
find_package(SUNDIALS 5.5.0 REQUIRED CONFIG | ||
PATHS ${SUNDIALS_DIR} | ||
${SUNDIALS_DIR}/lib/cmake/sundials) | ||
message(STATUS "SUNDIALS configuration found: ${SUNDIALS_CONFIG}") | ||
endif() | ||
if(GRIDKIT_ENABLE_SUNDIALS_SPARSE) | ||
include(FindSuiteSparse) | ||
set(CMAKE_INSTALL_RPATH ${SUITESPARSE_LIBRARY_DIR} ${CMAKE_INSTALL_RPATH}) | ||
endif() | ||
|
||
include_directories(${SUITESPARSE_INCLUDE_DIR} ${SUNDIALS_INCLUDE_DIR} ${IPOPT_INCLUDE_DIR}) | ||
|
||
# Set up configuration header file | ||
# configure_file(gridkit_config.h.in gridkit_config.h) | ||
|
||
# Macro that adds libraries | ||
include(GridkitAddLibrary) | ||
|
||
add_subdirectory(ComponentLib) | ||
add_subdirectory(Solver) | ||
add_subdirectory(Examples) | ||
|
||
# install(FILES gridkit_config.hpp DESTINATION include) | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
export(EXPORT gridkit-targets FILE "${CMAKE_CURRENT_BINARY_DIR}/GridKitTargets.cmake") | ||
|
||
# Configuring exporting cmake config | ||
install(EXPORT gridkit-targets | ||
FILE GridKitTargets.cmake | ||
NAMESPACE GRIDKIT:: | ||
DESTINATION lib/cmake/gridkit) | ||
|
||
include(CMakePackageConfigHelpers) | ||
|
||
# Basic version file | ||
write_basic_package_version_file( | ||
GridKitConfigVersion.cmake | ||
VERSION ${PACKAGE_VERSION} | ||
COMPATIBILITY SameMajorVersion) | ||
|
||
# Generate config file that includes exports | ||
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/config/Config.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/GridKitConfig.cmake" | ||
INSTALL_DESTINATION "lib/cmake/gridkit" | ||
NO_SET_AND_CHECK_MACRO | ||
NO_CHECK_REQUIRED_COMPONENTS_MACRO) | ||
|
||
# Install configuration file | ||
install(FILES | ||
${CMAKE_CURRENT_BINARY_DIR}/GridKitConfig.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/GridKitConfigVersion.cmake | ||
DESTINATION lib/cmake/gridkit) | ||
|
||
# TESTING | ||
enable_testing() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,14 @@ | |
# endorsement purposes. | ||
# | ||
|
||
add_library(Branch SHARED Branch.cpp) | ||
install(TARGETS Branch LIBRARY DESTINATION lib) | ||
# set(component_models ${component_models} Branch PARENT_SCOPE) | ||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
gridkit_add_library(branch | ||
SOURCES | ||
Branch.cpp | ||
OUTPUT_NAME | ||
gridkit_branch) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,16 @@ | |
# endorsement purposes. | ||
# | ||
|
||
add_library(Bus SHARED BusSlack.cpp BusPQ.cpp BusPV.cpp) | ||
install(TARGETS Bus LIBRARY DESTINATION lib) | ||
# set(component_models ${component_models} Bus PARENT_SCOPE) | ||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
gridkit_add_library(bus | ||
SOURCES | ||
BusPQ.cpp | ||
BusPV.cpp | ||
BusSlack.cpp | ||
OUTPUT_NAME | ||
gridkit_bus) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,11 @@ | |
# endorsement purposes. | ||
# | ||
|
||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
add_subdirectory(Branch) | ||
add_subdirectory(Bus) | ||
add_subdirectory(Generator2) | ||
|
@@ -63,4 +68,3 @@ add_subdirectory(Generator4Governor) | |
add_subdirectory(Generator4Param) | ||
add_subdirectory(Load) | ||
add_subdirectory(MiniGrid) | ||
set(component_models ${component_models} PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,14 @@ | |
# endorsement purposes. | ||
# | ||
|
||
add_library(Generator2 SHARED Generator2.cpp) | ||
install(TARGETS Generator2 LIBRARY DESTINATION lib) | ||
# set(component_models ${component_models} Generator2 PARENT_SCOPE) | ||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
gridkit_add_library(generator2 | ||
SOURCES | ||
Generator2.cpp | ||
OUTPUT_NAME | ||
gridkit_generator2) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,14 @@ | |
# endorsement purposes. | ||
# | ||
|
||
add_library(Generator4 SHARED Generator4.cpp) | ||
install(TARGETS Generator4 LIBRARY DESTINATION lib) | ||
# set(component_models ${component_models} Generator4 PARENT_SCOPE) | ||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
gridkit_add_library(generator4 | ||
SOURCES | ||
Generator4.cpp | ||
OUTPUT_NAME | ||
gridkit_generator4) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,14 @@ | |
# endorsement purposes. | ||
# | ||
|
||
add_library(Generator4Governor SHARED Generator4Governor.cpp) | ||
install(TARGETS Generator4Governor LIBRARY DESTINATION lib) | ||
# set(component_models ${component_models} Generator4Governor PARENT_SCOPE) | ||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
gridkit_add_library(generator4governor | ||
SOURCES | ||
Generator4Governor.cpp | ||
OUTPUT_NAME | ||
gridkit_generator4governor) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,14 @@ | |
# endorsement purposes. | ||
# | ||
|
||
add_library(Generator4Param Generator4Param.cpp) | ||
install(TARGETS Generator4Param LIBRARY DESTINATION lib) | ||
# set(component_models ${component_models} Generator4Param PARENT_SCOPE) | ||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
gridkit_add_library(generator4param | ||
SOURCES | ||
Generator4Param.cpp | ||
OUTPUT_NAME | ||
gridkit_generator4param) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,14 @@ | |
# endorsement purposes. | ||
# | ||
|
||
add_library(Load SHARED Load.cpp) | ||
install(TARGETS Load LIBRARY DESTINATION lib) | ||
# set(component_models ${component_models} Load PARENT_SCOPE) | ||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
gridkit_add_library(load | ||
SOURCES | ||
Load.cpp | ||
OUTPUT_NAME | ||
gridkit_load) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,14 @@ | |
# endorsement purposes. | ||
# | ||
|
||
add_library(MiniGrid SHARED MiniGrid.cpp) | ||
install(TARGETS MiniGrid LIBRARY DESTINATION lib) | ||
# set(component_models ${component_models} MiniGrid PARENT_SCOPE) | ||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
gridkit_add_library(minigrid | ||
SOURCES | ||
MiniGrid.cpp | ||
OUTPUT_NAME | ||
gridkit_minigrid) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,12 @@ | |
# endorsement purposes. | ||
# | ||
|
||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
add_executable(adjoint AdjointSensitivity.cpp) | ||
target_link_libraries(adjoint Bus Generator4 ${solver_libs}) | ||
install(TARGETS adjoint RUNTIME DESTINATION bin) | ||
target_link_libraries(adjoint GRIDKIT::bus GRIDKIT::generator4 GRIDKIT::solvers_dyn) | ||
install(TARGETS adjoint DESTINATION bin) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,12 @@ | |
# endorsement purposes. | ||
# | ||
|
||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
add_executable(dynconopt DynamicConstrainedOpt.cpp) | ||
target_link_libraries(dynconopt Bus Generator4 Generator2 ${solver_libs}) | ||
install(TARGETS dynconopt RUNTIME DESTINATION bin) | ||
target_link_libraries(dynconopt GRIDKIT::generator4 GRIDKIT::generator2 GRIDKIT::bus GRIDKIT::solvers_dyn GRIDKIT::solvers_opt) | ||
install(TARGETS dynconopt DESTINATION bin) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,11 @@ | |
# endorsement purposes. | ||
# | ||
|
||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
add_executable(genconstload GenConstLoad.cpp) | ||
target_link_libraries(genconstload Generator4Governor Bus Load ${solver_libs}) | ||
install(TARGETS genconstload RUNTIME DESTINATION bin) | ||
target_link_libraries(genconstload GRIDKIT::generator4governor GRIDKIT::bus GRIDKIT::load GRIDKIT::solvers_dyn GRIDKIT::solvers_opt) | ||
install(TARGETS genconstload DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,12 @@ | |
# endorsement purposes. | ||
# | ||
|
||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
add_executable(geninfbus GenInfiniteBus.cpp) | ||
target_link_libraries(geninfbus Bus Generator4 ${solver_libs}) | ||
install(TARGETS geninfbus RUNTIME DESTINATION bin) | ||
target_link_libraries(geninfbus GRIDKIT::bus GRIDKIT::generator4 GRIDKIT::solvers_opt GRIDKIT::solvers_dyn) | ||
install(TARGETS geninfbus DESTINATION bin) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,10 +55,15 @@ | |
# endorsement purposes. | ||
# | ||
|
||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
# add_executable(grid3bus Grid3Bus.cpp) | ||
# target_link_libraries(grid3bus MiniGrid ${solver_libs}) | ||
# target_link_libraries(grid3bus GRIDKIT::minigrid GRIDKIT::solvers_steady) | ||
# install(TARGETS grid3bus RUNTIME DESTINATION bin) | ||
|
||
add_executable(grid3bus Grid3BusSys.cpp) | ||
target_link_libraries(grid3bus MiniGrid Bus Branch Load ${solver_libs}) | ||
target_link_libraries(grid3bus GRIDKIT::minigrid GRIDKIT::bus GRIDKIT::branch GRIDKIT::load GRIDKIT::solvers_steady) | ||
install(TARGETS grid3bus RUNTIME DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,12 @@ | |
# endorsement purposes. | ||
# | ||
|
||
# [[ | ||
# Author(s): | ||
# - Cameron Rutherford <[email protected]> | ||
#]] | ||
|
||
add_executable(paramest ParameterEstimation.cpp) | ||
target_link_libraries(paramest Bus Generator4Param ${solver_libs}) | ||
target_link_libraries(paramest GRIDKIT::bus GRIDKIT::generator4param GRIDKIT::solvers_opt GRIDKIT::solvers_dyn) | ||
install(TARGETS paramest RUNTIME DESTINATION bin) | ||
install(FILES lookup_table.dat DESTINATION bin) |
Oops, something went wrong.