EPANET icon indicating copy to clipboard operation
EPANET copied to clipboard

No install(runepanet) in CMakeLists.txt

Open 0tkl opened this issue 1 year ago • 2 comments

I suggest adding something like

 target_include_directories(epanet2 PUBLIC ${PROJECT_SOURCE_DIR}/include)
 
+IF (NOT BUILD_PY_LIB)
+  install(TARGETS runepanet DESTINATION bin)
+ENDIF (NOT BUILD_PY_LIB)
 install(TARGETS epanet2 DESTINATION lib)
 install(FILES ./include/epanet2.h DESTINATION include)
 install(FILES ./include/epanet2_2.h DESTINATION include)

to CMakeList.txt. It would be helpful for packagers. Yeah, I have put it on Archlinux User Repo and I'd like to submit v2.3 to Debian in the future.

Btw, the BUILD_PY_LIB option looks counter-intuitive, from a packager's perspective. The library seems to be built under any input option, although it could be either static-linked or shared (controled by BUILD_SHARED_LIBS). If it doesn't break compatibility, I think flip BUILD_PY_LIB and use a more straightforward name BUILD_EXECUTABLE/BUILD_BIN would be better.

0tkl avatar May 29 '24 00:05 0tkl

I believe that the BUILD_PY_LIB option has been removed from the project so references to it in CMakeList.txt can be removed.

As for the install commands in CMakeList.txt, I suggest using the following:

install(TARGETS epanet2 DESTINATION bin)
install(TARGETS runepanet DESTINATION bin)
install(TARGETS epanet-output 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/outfile/include DESTINATION lib)

When the cmake --install . -- prefix <install location> command is invoked (under Windows), files will be placed in the installation directory as follows:

  • epanet2.dll, epanet2.lib, and runepanet.exe in a bin folder
  • epanet2.h, epanet2_2.h, and epanet2_enums.h in an include folder
  • epanet-output.dll and epanet-output.lib in a lib folder
  • the three .h files used by epanet-output in a lib/include folder.

Are people OK with this layout or is there a better alternative?

LRossman avatar Apr 01 '25 03:04 LRossman

I'm now thinking that using a multi-folder layout for files installed using Cmake is overkill since there's only five files that clients might use. Therefore the following install directives in CmakeFile.txt would suffice:

install(TARGETS epanet2 DESTINATION .)
install(TARGETS runepanet DESTINATION .)
install(FILES ./include/epanet2.h DESTINATION .)
install(FILES ./include/epanet2_2.h DESTINATION .)
install(FILES ./include/epanet2_enums.h DESTINATION .)

They place all files together in the directory supplied with the Cmake install command. I've omitted the epanet-output files since they are only used internally for CI testing and there's no documentation provided for them.

LRossman avatar Apr 01 '25 15:04 LRossman