From 0c3d444eef7b265582bb051d8e83963f608d2346 Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Mon, 12 Feb 2024 11:47:35 -0500 Subject: [PATCH 1/2] enhances build files with INSTALL options and fixes Conan --- BUILDING.md | 9 +++++++++ CMakeLists.txt | 11 +++++++++-- conanfile.py | 9 +++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 6e99a475..a1db2b64 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -24,6 +24,15 @@ These two scripts build EPANET binaries for both the 32 and 64 bit Windows platf A tutorial on [building OWA EPANET from source on Windows](tools/BuildAndTest.md), including running unit tests and performing regression testing, is also avaiable. +## Alternative build with Conan +Conan is an increasingly popular C/C++ package management suite. To build EPANET using Conan, use the following commands as a starting point: + +``` +conan build . -s build_type=Release +conan export-pkg . -s build_type=Release +``` + + # Testing Unit tests have been written using the Boost Unit Testing Framework and other Boost libraries. The tests are compiled into individual executables that automatically perform checks on the EPANET toolkit and output libraries. diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fdcd7ce..b912cfc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,11 +32,11 @@ project(EPANET) # Append local dir to module search path list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) option(BUILD_TESTS "Build tests (requires Boost)" OFF) option(BUILD_PY_LIB "Build library for Python wrapper" OFF) option(BUILD_COVERAGE "Build library for coverage" OFF) - IF (NOT BUILD_PY_LIB) add_subdirectory(run) ENDIF (NOT BUILD_PY_LIB) @@ -96,7 +96,14 @@ IF(MSVC AND "${CMAKE_VS_PLATFORM_NAME}" MATCHES "(Win32)") add_library(epanet2 SHARED ${EPANET_LIB_ALL} ${PROJECT_SOURCE_DIR}/include/epanet2.def) set_source_files_properties(${PROJECT_SOURCE_DIR}/include/epanet2.def PROPERTIES_HEADER_FILE_ONLY TRUE) ELSE(TRUE) - add_library(epanet2 SHARED ${EPANET_LIB_ALL}) + add_library(epanet2 ${EPANET_LIB_ALL}) ENDIF(MSVC AND "${CMAKE_VS_PLATFORM_NAME}" MATCHES "(Win32)") target_include_directories(epanet2 PUBLIC ${PROJECT_SOURCE_DIR}/include) + +install(TARGETS epanet2 DESTINATION lib) +install(FILES ./include/epanet2.h DESTINATION include) +install(FILES ./include/epanet2_2.h DESTINATION include) +install(DIRECTORY ./src/ DESTINATION include FILES_MATCHING PATTERN "*.h") + + diff --git a/conanfile.py b/conanfile.py index fb9db095..93c741c6 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,4 +1,4 @@ -from conans import ConanFile +from conan import ConanFile from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout class EpanetConan(ConanFile): @@ -33,11 +33,8 @@ def build(self): cmake.build() def package(self): - self.copy("lib/libepanet2.dylib", "lib", keep_path=False) - self.copy("lib/libepanet-output.dylib", "lib", keep_path=False) - self.copy("*.h", "include", "include", keep_path=False) - self.copy("types.h", "include", "src", keep_path=False) - self.copy("hash.h", "include", "src", keep_path=False) + cmake = CMake(self) + cmake.install() def package_info(self): self.cpp_info.libdirs = ["lib"] From efe4e218461ee3dc473256bf7eee7ad3151067b2 Mon Sep 17 00:00:00 2001 From: Sam Hatchett Date: Tue, 9 Apr 2024 13:32:28 -0400 Subject: [PATCH 2/2] fixes conan build, adds enums to cmake --- CMakeLists.txt | 1 + conanfile.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b912cfc4..108303bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,7 @@ target_include_directories(epanet2 PUBLIC ${PROJECT_SOURCE_DIR}/include) install(TARGETS epanet2 DESTINATION lib) install(FILES ./include/epanet2.h DESTINATION include) install(FILES ./include/epanet2_2.h DESTINATION include) +install(FILES ./include/epanet2_enums.h DESTINATION include) install(DIRECTORY ./src/ DESTINATION include FILES_MATCHING PATTERN "*.h") diff --git a/conanfile.py b/conanfile.py index 93c741c6..089221fd 100644 --- a/conanfile.py +++ b/conanfile.py @@ -38,5 +38,5 @@ def package(self): def package_info(self): self.cpp_info.libdirs = ["lib"] - self.cpp_info.libs = ["epanet2", "epanet-output"] + self.cpp_info.libs = ["epanet2"] self.cpp_info.includedirs = ["include"]