FairRootGroup / FairSoft

Repository for installation routines of the external software required by FairRoot
GNU Lesser General Public License v3.0
16 stars 61 forks source link

Specifying -DCMAKE_INSTALL_PREFIX doesn't change the install prefix #549

Open YanzhaoW opened 1 month ago

YanzhaoW commented 1 month ago

Hi,

I'm installing FairSoft-jan24p2. After unzipping the tar bar downloaded from the release page and configure the cmake with:

cmake -DCMAKE_INSTALL_PREFIX=/opt/FairSoft/jan24p2 -S . -B ./build -C ./FairSoftConfig.cmake

The print out from the CMake still has:

--   INSTALL PREFIX     /lustre/r3b/ywang/software/FairSoft-jan24p2/install (change with -DCMAKE_INSTALL_PREFIX=...)

which shows the install prefix is pointing to the default location, instead of the new location specified from the command line.

dennisklein commented 1 month ago

It seems the precedence of which CMAKE_INSTALL_PREFIX value is taken is determined by the command-line argument order, try

cmake -S . -B ./build -C ./FairSoftConfig.cmake -DCMAKE_INSTALL_PREFIX=/opt/FairSoft/jan24p2
YanzhaoW commented 1 month ago

I think the problem is caused by this line: https://github.com/FairRootGroup/FairSoft/blob/5537f58e609219ec54b32fb766d7d705c7bef399/FairSoftConfig.cmake#L17

I feel this is a bit anti-pattern to hard-code a common cache variable in the script.

What's the problem to just set it without FORCE?

set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "Install prefix") 

Then if a user provides any CMAKE_INSTALL_PREFIX by setting the flag in any position, this line will not overwrite the value.

dennisklein commented 1 month ago

I have no objections against removing the FORCE if that helps.