rcsb / mmtf-cpp

The pure C++ implementation of the MMTF API, decoder and encoder.
MIT License
21 stars 24 forks source link

msgpack-c/include not detected, despite directory being present #18

Closed fusion809 closed 6 years ago

fusion809 commented 6 years ago

Hi,

I have written a spec file for building this in the openSUSE Build Service (OBS). Here it is in full. In it I'm essentially downloading a tar.gz archive of:

  1. Commit 63e58a9057ee684b5a0a409932e7fc2126894fc0 of this repository.
  2. Commit 7a98138f27f27290e680bf8fbf1f8d1b089bf138 of the msgpack-c repository.
  3. Commit 8c8883457e54fb460908a57d801212c56a603aec of the mmtf_spec repo.
  4. Commit cf4b7eead92773932f32c7efd2612e9d27b07557 of the Catch2 repo.

Then:

Then running (most of this is inherited from the %cmake macro):

    find . -name CMakeLists.txt \
        -exec sed -i -re '/^[[:blank:]]*[sS][eE][tT][[:blank:]]*\([[:blank:]]*(CMAKE_BUILD_TYPE|CMAKE_COLOR_MAKEFILE|CMAKE_INSTALL_PREFIX|CMAKE_VERBOSE_MAKEFILE).*\)/{s/^/#IGNORE /}' {} + 
    mkdir -p build 
    cd build 
    /usr/bin/cmake $OLDPWD/. \
        -G"Unix Makefiles" \
        -DCMAKE_INSTALL_PREFIX:PATH=/usr \
        -DINCLUDE_INSTALL_DIR:PATH=/usr/include \
        -DLIB_INSTALL_DIR:PATH=/usr/lib64 \
        -DSYSCONF_INSTALL_DIR:PATH=/etc \
        -DSHARE_INSTALL_PREFIX:PATH=/usr/share \
        -DCMAKE_INSTALL_LIBDIR:PATH=/usr/lib64 \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -DCMAKE_C_FLAGS="${CFLAGS:--O2 -g -m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables} -DNDEBUG" \
        -DCMAKE_CXX_FLAGS="${CXXFLAGS:--O2 -g -m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables} -DNDEBUG" \
        -DCMAKE_Fortran_FLAGS="${FFLAGS:--O2 -g -m64 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables} -DNDEBUG" \
        -DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed -Wl,--no-undefined -Wl,-z,now" \
        -DCMAKE_MODULE_LINKER_FLAGS="-Wl,--as-needed" \
        -DCMAKE_SHARED_LINKER_FLAGS="-Wl,--as-needed -Wl,--no-undefined -Wl,-z,now" \
%if "lib64" == "lib64" 
        -DLIB_SUFFIX=64 \
%endif 
        -DCMAKE_SKIP_RPATH:BOOL=ON \
        -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
        -DBUILD_SHARED_LIBS:BOOL=ON \
        -DBUILD_STATIC_LIBS:BOOL=OFF \
        -DCMAKE_COLOR_MAKEFILE:BOOL=OFF \
        -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF \
        -DCMAKE_MODULES_INSTALL_DIR=/usr/share/cmake/Modules \
        -DCMAKE_BUILD_TYPE:STRING=Release \
        -DMSGPACKC_INCLUDE_DIR=msgpack-c/include

(and yes I have tried omitting the final line and it returned the same error as it doesn't seem to be recognized by cmake) and I received the output:

[    2s] + /usr/bin/cmake /home/abuild/rpmbuild/BUILD/mmtf-cpp-63e58a9057ee684b5a0a409932e7fc2126894fc0/. '-GUnix Makefiles' -DCM                                                                                                                                      AKE_INSTALL_PREFIX:PATH=/usr -DINCLUDE_INSTALL_DIR:PATH=/usr/include -DLIB_INSTALL_DIR:PATH=/usr/lib64 -DSYSCONF_INSTALL_DIR:PATH                                                                                                                                      =/etc -DSHARE_INSTALL_PREFIX:PATH=/usr/share -DCMAKE_INSTALL_LIBDIR:PATH=/usr/lib64 -DCMAKE_BUILD_TYPE=RelWithDebInfo '-DCMAKE_C_                                                                                                                                      FLAGS=-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protectio                                                                                                                                      n -DNDEBUG' '-DCMAKE_CXX_FLAGS=-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-table                                                                                                                                      s -fstack-clash-protection -DNDEBUG' '-DCMAKE_Fortran_FLAGS=-O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-table                                                                                                                                      s -fasynchronous-unwind-tables -fstack-clash-protection -DNDEBUG' '-DCMAKE_EXE_LINKER_FLAGS=-Wl,--as-needed -Wl,--no-undefined -W                                                                                                                                      l,-z,now' -DCMAKE_MODULE_LINKER_FLAGS=-Wl,--as-needed '-DCMAKE_SHARED_LINKER_FLAGS=-Wl,--as-needed -Wl,--no-undefined -Wl,-z,now'                                                                                                                                       -DLIB_SUFFIX=64 -DCMAKE_SKIP_RPATH:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON -DBUILD_STATIC_LIBS:BOOL                                                                                                                                      =OFF -DCMAKE_COLOR_MAKEFILE:BOOL=OFF -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF -DCMAKE_MODULES_INSTALL_DIR=/usr/share/cmake/Modules -DCMA                                                                                                                                      KE_BUILD_TYPE:STRING=Release -DMSGPACKC_INCLUDE_DIR=msgpack-c/include                                                                                                                                                                                                  
[    3s] -- The CXX compiler identification is GNU 8.2.1                                                                                                                                                                                                               
[    3s] -- Check for working CXX compiler: /usr/bin/c++                                                                                                                                                                                                               
[    3s] -- Check for working CXX compiler: /usr/bin/c++ -- works                                                                                                                                                                                                      
[    3s] -- Detecting CXX compiler ABI info                                                                                                                                                                                                                            
[    3s] -- Detecting CXX compiler ABI info - done                                                                                                                                                                                                                     
[    3s] -- Detecting CXX compile features                                                                                                                                                                                                                             
[    4s] -- Detecting CXX compile features - done                                                                                                                                                                                                                      
[    4s] CMake Warning at CMakeLists.txt:29 (find_package):                                                                                                                                                                                                            
[    4s]   By not providing "Findmsgpack.cmake" in CMAKE_MODULE_PATH this project has                                                                                                                                                                                  
[    4s]   asked CMake to find a package configuration file provided by "msgpack", but                                                                                                                                                                                 
[    4s]   CMake did not find one.                                                                                                                                                                                                                                     
[    4s]                                                                                                                                                                
[    4s]   Could not find a package configuration file provided by "msgpack" with any                                                                                                                                                                                  
[    4s]   of the following names:                                                                                                                                                                                                                                     
[    4s]                                                                                                                                                                
[    4s]     msgpackConfig.cmake                                                                                                                                                                                                                                    
[    4s]     msgpack-config.cmake                                                                                                                                                                                                                                      
[    4s]                                                                                                                                                                
[    4s]   Add the installation prefix of "msgpack" to CMAKE_PREFIX_PATH or set                                                                                                                                                                                        
[    4s]   "msgpack_DIR" to a directory containing one of the above files.  If                                                                                                                                                                                         
[    4s]   "msgpack" provides a separate development package or SDK, be sure it has                                                                                                                                                                                    
[    4s]   been installed.                                                                                                                                                                                                                  
[    4s]                                                                                                                                                                
[    4s]                                                                                                                                                                
[    4s] -- Configuring done                                                                                                                                                                                                                        
[    4s] -- Generating done                                                                                                                                                                                                                     
[    4s] CMake Warning:                                                                                                                                                                                                         
[    4s]   Manually-specified variables were not used by the project:                                                                                                                                                                                                  
[    4s]                                                                                                                                                                
[    4s]     BUILD_STATIC_LIBS                                                                                                                                                                                                                              
[    4s]     CMAKE_C_FLAGS
[    4s]     CMAKE_Fortran_FLAGS
[    4s]     CMAKE_INSTALL_DO_STRIP
[    4s]     CMAKE_INSTALL_LIBDIR
[    4s]     CMAKE_MODULES_INSTALL_DIR
[    4s]     CMAKE_SKIP_RPATH
[    4s]     INCLUDE_INSTALL_DIR
[    4s]     LIB_INSTALL_DIR
[    4s]     LIB_SUFFIX
[    4s]     MSGPACKC_INCLUDE_DIR
[    4s]     SHARE_INSTALL_PREFIX
[    4s]     SYSCONF_INSTALL_DIR
[    4s] 
[    4s] 

(ignore the [ ns] at the start that's related to the OBS). I've checked out your CMakeLists.txt file and it seems like cmake should run fine without any need to manually specify the MSGPACKC_INCLUDE_DIR variable, so long as the msgpack-c source directory is in the top level of this project's source directory. So since this is the case, this would seem to qualify as a bug in this project's cmake set up.

Thanks for your time, Brenton

danpf commented 6 years ago

Hey Brenton I don't know much about OBS but i can try

the workflow i normally use is on the README

1. git submodule update --init --recursive
2. mkdir build
3. cd build
4. cmake -G Ninja -DBUILD_TESTS=ON -Dmmtf_build_local=ON -Dmmtf_build_examples=ON ..
5. ninja
6. chmod +x ./tests/mmtf_tests
7. ./tests/mmtf_tests

you're doing step 1 manually

you should probably add lines to do steps 2 and 3

then it looks like this command %cmake -DCMAKE_BUILD_TYPE:STRING=Release -DMSGPACKC_INCLUDE_DIR=msgpack-c/include

should be cmake -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_TESTS=OFF -Dmmtf_build_local=ON -Dmmtf_build_examples=OFF .. or no .. at the end if you don't want to build in build

We have mmtf_build_local if you want to use our msgpack (it looks like you do) but since applications might package their own messagepack (usually installed into the system via apt-get or yum, or just their own submodule of messagepack-c)

There might be a bug in the CMakeLists.txt, but since FindMsgpack.cmake isn't packaged with msgpack-c, it's difficult to know what we should actually be searching for with find_package(msgpack)

let me know if that helps!

fusion809 commented 6 years ago

It helps, it's just now I'm surprised there's no install target in the Makefile and I'm not sure how to install mmtf system-wide now. I'm not sure which files to copy across. Some are obvious like the includes/ folder, build/examples/ and build/tests/ directory.

fusion809 commented 6 years ago

See I'm making a package for MMTF in the openSUSE Build Service as it is now a build dependency of Avogadro2 (I build a bleeding-edge package for it),

gtauriello commented 6 years ago

The library is include only and as such I believe that it is sufficient to just copy the content of the include folders (include and msgpack-c/include) into a system-wide include folder. The build/examples and build/tests are just meant as examples and tests and as such are not necessary for an installation for anyone wanting to use mmtf-cpp.

fusion809 commented 6 years ago

Thanks mate. That's what I love about open-source, how helpful people tend to be to their fellow human being.