Menu

#12 CMAKE_INSTALL_PREFIX can't be set by user.

fgms-1.0
closed
None
5
2022-04-20
2018-09-26
No

It doesn't matter if the CMAKE_INSTALL_PREFIX is set explicitly by user,

the CMakeLists.txt:46 IF(NOT DEFINED USER_INSTALL_PREFIX) IF-ELSE conditional block will always exit before the ELSE clause, setting CMAKE_INSTALL_PREFIX to "/usr".

How is USER_INSTALL_PREFIX intended to work?

I've swapped the code between IF-ELSE clauses for now, it seems to work for me when setting CMAKE_INSTALL_PREFIX.

Discussion

  • Geoff

    Geoff - 2018-09-26

    Yes, I just notice my build script, which includes an option -DCMAKE_INSTALL_PREFIX=/path is completely ignored...

    Have you tried adding an option -DUSER_INSTALL_PREFIX=/some/path? This seems to work for me...

    But certainly agree it is a bit confusing...

     
  • Oliver Schroeder

    • status: open --> pending
    • assigned_to: Oliver Schroeder
     
  • Oliver Schroeder

     
  • Oliver Schroeder

    This one is curious. I wonder why we have USER_INSTALL_PREFIX in CMakeLists.txt. If USER_INSTALL_PREFIX is not set explicitly set CMAKE_INSTALL_PREFIX to /usr. I removed this completly in 0.13.4...
    Please test.

     
  • Geoff

    Geoff - 2018-10-08

    In 0.13.4, a quick Window compile test found I needed the following patch -

    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index 82361cc..751ca2b 100755
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -88,6 +88,7 @@ if(WIN32)
         configure_file( "${CMAKE_SOURCE_DIR}/config.h.msvc" "${CMAKE_BINARY_DIR}/config.h" COPYONLY)
         file(WRITE "${CMAKE_BINARY_DIR}/unistd.h" "/* dummy unistd.h for windows */") 
     else(WIN32)
    +    set ( EXTRA_FLAGS "-std=c++11" )
         if(ENABLE_DEBUG_SYMBOLS)
             list(APPEND EXTRA_FLAGS "-g")
         endif(ENABLE_DEBUG_SYMBOLS)
    @@ -103,7 +104,6 @@ if(BUILD_SERVER2)
         message(STATUS "*** Building server 2. File fg_server2.log fgms_exit2 fgms_reset2 fgms_stat2 fgms2.conf")
     endif(BUILD_SERVER2)
    
    -set ( EXTRA_FLAGS "-std=c++11" )
     set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${EXTRA_FLAGS} -D_REENTRANT" )
     set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${EXTRA_FLAGS} -D_REENTRANT" )
     set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_LD_FLAGS}" )
    

    For some reason the set ( EXTRA_FLAGS "-std=c++11" ), which should only apply to if (NOT WIN32) got moved outside the if (WIN32) ... else () here endif (), and clobbers other needed Windows only EXTRA_FLAGS ...

    No time to investigate more now... but it would be great if it could be moved back into what is effectively an if (NOT WIN32) zone... is this just a simple move mistake?

     
  • Hamza Alloush

    Hamza Alloush - 2018-11-02

    This was fixed in 874f10ac50e359f3a7d2868da8cc0571c01cfc51

    a straight up -DCMAKE_INSTALL_PREFIX:PATH=/opt, correctly deploys on an Entware /opt partition, makefile:47 :

    #
    # Copyright (C) 2017 OpenWrt.org
    #
    # This is free software, licensed under the GNU General Public License v2.
    # See /LICENSE for more information.
    #
    
    include $(TOPDIR)/rules.mk
    
    PKG_LICENSE:=GPL-2.0
    PKG_MAINTAINER:=Hamza Alloush <hamzaalloush@live.com>
    
    PKG_NAME:=fgms
    PKG_VERSION:=0.13.4
    PKG_RELEASE:=1
    
    PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
    PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
    PKG_SOURCE_URL:=git://git.code.sf.net/p/fgms/src
    PKG_SOURCE_VERSION:=95dd51f95dfac74622c23e33cae7f8060a545a65
    PKG_MIRROR_HASH:=886cf69e04a3260c0036b3f18d7167e38f1f31f3d87750f1a7ca469cb3d24c82
    
    PKG_BUILD_ROOT:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
    PKG_BUILD_DIR:=$(PKG_BUILD_ROOT)
    
    PKG_INSTALL:=1
    CMAKE_INSTALL:=1
    
    include $(INCLUDE_DIR)/package.mk
    include $(INCLUDE_DIR)/cmake.mk
    
    define Package/fgms
      SECTION:=net
      CATEGORY:=Network
      URL:=$(PKG_SOURCE_URL)
      TITLE:=FlightGear Multi Player Server
      DEPENDS:=+libpthread +libstdcpp
    endef
    
    define Package/fgms/description
     The FlightGear MultiPlayer Server (fgms) is a standalone network server that 
    powers the FlightGear MP Network. It allows flying with other pilots 
    over a network inside fgfs.
    endef
    
    CMAKE_OPTIONS = \
        -DCMAKE_INSTALL_PREFIX:PATH=/opt \
        -DCMAKE_BUILD_TYPE:STRING=Release \
        -DCMAKE_CXX_FLAGS:STRING="-Wall"
    
    define Package/fgms/conffiles
    /opt/etc/fgms.conf
    endef
    
    define Package/fgms/install
        $(INSTALL_DIR) $(1)/opt/sbin
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/opt/sbin/fgms $(1)/opt/sbin
    
        $(INSTALL_DIR) $(1)/opt/etc
        $(INSTALL_BIN) ./files/fgms.conf $(1)/opt/etc
    
        $(INSTALL_DIR) $(1)/opt/etc/init.d
        $(INSTALL_BIN) ./files/S99fgms $(1)/opt/etc/init.d
    endef
    
    $(eval $(call BuildPackage,fgms))
    

    installing compiled package:

    $ opkg install ./fgms_0.13.4-1_armv7soft.ipk

    checking all files installed by package:

    $ opkg files fgms
    Package fgms (0.13.4-1) is installed on root and has the following files:
    /opt/etc/fgms.conf
    /opt/etc/init.d/S99fgms
    /opt/sbin/fgms

    Thank you. i think this is solved, using standard CMAKE_INSTALL_PREFIX works.

     
  • Megaf

    Megaf - 2021-07-08

    -DCMAKE_INSTALL_PREFIX. still not working in the master branch at least.

     
  • Oliver Schroeder

    • status: pending --> closed
     
  • Oliver Schroeder

    fixed in 0.13.7

     

Log in to post a comment.