Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow install in generic locations #17

@davidedelvento

Description

@davidedelvento

I am no export of cmake by any means, so this is not worth a pull request because it is not working as I would like. Reading the documentation about install and CMAKE_INSTALL_PREFIX I could not come with a setting that I liked, namely that would:

  • install in $WHATEVER if -DCMAKE_INSTALL_PREFIX=$WHATEVER is specified when invoking cmake
  • install in /usr/local/chidg/ if -DCMAKE_INSTALL_PREFIX is not specified when invoking cmake

If I leave CMakeList.txt as is, I could have it installed in $WHATEVER/usr/local/chidg/ by calling make DESTDIR=$WHATEVER install instead of make install but I don't really like the /usr/local/chidg/ suffix.

The following does what I want for me (installing in $WHATEVER), but of course not for you since it installs in /usr/local/ instead of /usr/local/chidg/.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ff6a14..3e31558 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -301,11 +301,11 @@ set_target_properties(chidg PROPERTIES
 #                                       Install targets
 #----------------------------------------------------------------------------------------------
 install(TARGETS chidg coredg
-        RUNTIME DESTINATION /usr/local/chidg/bin
-        LIBRARY DESTINATION /usr/local/chidg/lib
-        ARCHIVE DESTINATION /usr/local/chidg/lib)
+        RUNTIME DESTINATION bin
+        LIBRARY DESTINATION lib
+        ARCHIVE DESTINATION lib)
 
-install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION /usr/local/chidg/include)
+install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION include)

If I had removed only /usr/local/ instead of removing the whole /usr/local/chidg/ from the DESTINATIONS my understanding was that it would work for you and it would be better for me (installing in $WHATEVER/chidg/ when calling make DESTDIR=$WHATEVER install instead of make install). But I still don't like the additional /chidg/ suffix. Yet, this still install in very ugly $WHATEVER/usr/local/chidg/. Just to be super clear about what I'm doing:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ff6a14..224f830 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -301,11 +301,11 @@ set_target_properties(chidg PROPERTIES
 #                                       Install targets
 #----------------------------------------------------------------------------------------------
 install(TARGETS chidg coredg
-        RUNTIME DESTINATION /usr/local/chidg/bin
-        LIBRARY DESTINATION /usr/local/chidg/lib
-        ARCHIVE DESTINATION /usr/local/chidg/lib)
+        RUNTIME DESTINATION chidg/bin
+        LIBRARY DESTINATION chidg/lib
+        ARCHIVE DESTINATION chidg/lib)
 
-install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION /usr/local/chidg/include)
+install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION chidg/include)

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions