Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Error set_property can not be used on an ALIAS target #402

Closed
samfux84 opened this issue Jun 28, 2019 · 9 comments
Closed

CMake Error set_property can not be used on an ALIAS target #402

samfux84 opened this issue Jun 28, 2019 · 9 comments

Comments

@samfux84
Copy link

Hi,

I am using CMake 3.12.4 to build eman2 from source (I also tested with CMake 3.14.4 and got the same error) and got the following error:

 CMake Error at /cluster/apps/gcc-4.8.5/cmake-3.14.4-2yckzriatk5ei7cuqncwz5il26gb63oz/share/cmake-3.14/Modules/FindFreetype.cmake:178
 (set_property):
   set_property can not be used on an ALIAS target.
 Call Stack (most recent call first):
   cmake/Freetype.cmake:1 (find_package)
   cmake/FindFTGL.cmake:27 (include)
   libEM/CMakeLists.txt:180 (find_package)

Is this a known problem ?

What version of CMake do you recommend to build eman2 ?

Any help is appreciated.

@shadowwalkersb
Copy link
Member

The minimum version of cmake to build eman2 is 3.9, but it should work with higher versions, too. Which branch is the source from?

@samfux84
Copy link
Author

I use the release tarball

https://github.com/cryoem/eman2/archive/v2.3.tar.gz

@shadowwalkersb
Copy link
Member

I have tried a few versions of cmake, 3.14.0, 3.14.5, 3.12.2 and 3.9.4, with the tarball, but can't reproduce this.

@samfux84
Copy link
Author

samfux84 commented Jul 2, 2019

Hi,

Maybe this is due to building the dependencies manually and not with Conda.

When I empty the build directory of EMAN2 and use ccmake to set the variables

ccmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG -ftree-vectorize -march=core-avx2 -mavx2" -DPYTHON_EXECUTABLE=/cluster/apps/python/2.7.14/bin/python -DCMAKE_INSTALL_PREFIX=/cluster/apps/eman2/2.3/x86_64 -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_EMAN_CUDA=ON -DENABLE_OPTIMIZE_X86_64=ON -DFFTW3D_INCLUDE_PATH=/cluster/apps/gcc-4.8.5/fftw-3.3.5-xqwrft73uae7gismovk2xugrzrzjw2oz/include -DFFTW3D_THREADS_INCLUDE_PATH=/cluster/apps/gcc-4.8.5/fftw-3.3.5-xqwrft73uae7gismovk2xugrzrzjw2oz/include -DFFTW3F_INCLUDE_PATH=/cluster/apps/gcc-4.8.5/fftw-3.3.5-xqwrft73uae7gismovk2xugrzrzjw2oz/include -DFFTW3F_THREADS_INCLUDE_PATH=/cluster/apps/gcc-4.8.5/fftw-3.3.5-xqwrft73uae7gismovk2xugrzrzjw2oz/include -DFTGL_INCLUDE_PATH=/cluster/apps/ftgl/2.1.3/x86_64/include -DZLIB_LIBRARY_RELEASE=/cluster/apps/gcc-4.8.5/zlib-1.2.11-bq2w5h6vcd64cmfueygcbug4fksi4eb4/include/lib/libz.so -DPNG_LIBRARY_RELEASE=/cluster/apps/gcc-4.8.5/libpng-1.6.27-d6quyddan2eotsexesxufytusf27xxgz/lib/libpng.so -DGSL_ROOT_DIR=/cluster/apps/gcc-4.8.5/gsl-2.3-xwny6fotw5xcpchcbhl4oyughsocriam -Dpkgcfg_lib_GSL_gsl=/cluster/apps/gcc-4.8.5/gsl-2.3-xwny6fotw5xcpchcbhl4oyughsocriam/lib/libgsl.so -DFTGL_LIBRARY=/cluster/apps/ftgl/2.1.3/x86_64/lib/libftgl.so -DCUDA_VERBOSE_BUILD=ON -DHDF5_INCLUDE_PATH=/cluster/apps/gcc-4.8.5/hdf5-1.10.1-v5tokcw5ende26jt6iufdt25yspgjzw2/include -DFREETYPE_INCLUDE_DIR=/cluster/apps/gcc-4.8.5/freetype-2.7-mhhi2pufcglnyisabx7ha4ylcuyqmf3u/include ..

Then I configure twice by typing "c" in the CMake gui and get the following output:

CMAKE_PREFIX_PATH: /cluster/apps/eman2/2.3/x86_64;/cluster/apps/eman2/2.3/x86_64/..

 PYTHON_EXECUTABLE:   /cluster/apps/python/2.7.14/bin/python

 PYTHON_LIBRARIES:    /cluster/apps/python/2.7.14/lib64/libpython2.7.so

 PYTHON_INCLUDE_DIRS: /cluster/apps/python/2.7.14/include/python2.7

 PYTHON_INCLUDE_PATH: /cluster/apps/python/2.7.14/include/python2.7

 PYTHON_INCLUDE_DIR:  /cluster/apps/python/2.7.14/include/python2.7

 Python site-packages: /cluster/apps/python/2.7.14/lib64/python2.7/site-packages

 NUMPY_INCLUDE_DIR: /cluster/apps/python/2.7.14/lib64/python2.7/site-packages/numpy/core/include

 CMake Warning (dev) at libEM/CMakeLists.txt:109 (find_package):
   Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
   Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
   command to set the policy and suppress this warning.

   Environment variable GSL_ROOT is set to:

     /cluster/apps/gcc-4.8.5/gsl-2.3-xwny6fotw5xcpchcbhl4oyughsocriam

   For compatibility, CMake is ignoring the variable.
 This warning is for project developers.  Use -Wno-dev to suppress it.


 TIFF_LIBRARIES: /cluster/apps/gcc-4.8.5/libtiff-4.0.6-y76bcjaualcxv3hld235ducq3oski7wf/lib/libtiff.so

 CMake Warning (dev) at cmake/JPEG.cmake:1 (find_package):
   Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
   Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
   command to set the policy and suppress this warning.

   Environment variable JPEG_ROOT is set to:

     /cluster/apps/gcc-4.8.5/jpeg-9b-psjvucpx7xwkflb3meatuo6ugdtapkex
 
   For compatibility, CMake is ignoring the variable.
 Call Stack (most recent call first):
   libEM/CMakeLists.txt:127 (include)
 This warning is for project developers.  Use -Wno-dev to suppress it.


 JPEG_LIBRARIES: /cluster/apps/gcc-4.8.5/jpeg-9b-psjvucpx7xwkflb3meatuo6ugdtapkex/lib/libjpeg.so

 HDF5_LIBRARY: /cluster/apps/gcc-4.8.5/hdf5-1.10.1-v5tokcw5ende26jt6iufdt25yspgjzw2/lib/libhdf5.so

 CMake Warning (dev) at /cluster/apps/gcc-4.8.5/cmake-3.12.4-letepnmurt7hl5seixgddx24xniq2rwz/share/cmake-3.12/Modules/FindPNG.cmake:51
 (find_package):
   Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
   Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
   command to set the policy and suppress this warning.

   Environment variable ZLIB_ROOT is set to:

     /cluster/apps/gcc-4.8.5/zlib-1.2.11-bq2w5h6vcd64cmfueygcbug4fksi4eb4

   For compatibility, CMake is ignoring the variable.
 Call Stack (most recent call first):
   cmake/PNG.cmake:1 (find_package)
   libEM/CMakeLists.txt:136 (include)
 This warning is for project developers.  Use -Wno-dev to suppress it.

 PNG_LIBRARIES:
 /cluster/apps/gcc-4.8.5/libpng-1.6.27-d6quyddan2eotsexesxufytusf27xxgz/lib/libpng.so;/cluster/apps/gcc-4.8.5/zlib-1.2.11-bq2w5h6vcd64cmfuey
 gcbug4fksi4eb4/include/lib/libz.so

 CMAKE_LIBRARY_ARCHITECTURE:

 OPENGL_INCLUDE_DIR: /cluster/apps/gcc-4.8.5/mesa-12.0.3-ml7hu2oihsajd36kowkabf4d4zeo5ydm/include

 OPENGL_LIBRARIES:
 /cluster/apps/gcc-4.8.5/mesa-12.0.3-ml7hu2oihsajd36kowkabf4d4zeo5ydm/lib/libGL.so;/cluster/apps/gcc-4.8.5/mesa-glu-9.0.0-dm3qf5nckseq6wbe2v
 h5tubcyfjafcv6/lib/libGLU.so

 CMake Error at /cluster/apps/gcc-4.8.5/cmake-3.12.4-letepnmurt7hl5seixgddx24xniq2rwz/share/cmake-3.12/Modules/FindFreetype.cmake:173
 (set_target_properties):
   set_target_properties can not be used on an ALIAS target.
 Call Stack (most recent call first):
   cmake/Freetype.cmake:1 (find_package)
   cmake/FindFTGL.cmake:27 (include)
   libEM/CMakeLists.txt:180 (find_package)



 CMake Error at /cluster/apps/gcc-4.8.5/cmake-3.12.4-letepnmurt7hl5seixgddx24xniq2rwz/share/cmake-3.12/Modules/FindFreetype.cmake:177
 (set_property):
   set_property can not be used on an ALIAS target.
 Call Stack (most recent call first):
   cmake/Freetype.cmake:1 (find_package)
   cmake/FindFTGL.cmake:27 (include)
   libEM/CMakeLists.txt:180 (find_package)



 CMake Error at /cluster/apps/gcc-4.8.5/cmake-3.12.4-letepnmurt7hl5seixgddx24xniq2rwz/share/cmake-3.12/Modules/FindFreetype.cmake:179
 (set_target_properties):
   set_target_properties can not be used on an ALIAS target.
 Call Stack (most recent call first):
   cmake/Freetype.cmake:1 (find_package)
   cmake/FindFTGL.cmake:27 (include)
   libEM/CMakeLists.txt:180 (find_package)



 FREETYPE_LIBRARIES:    /cluster/apps/gcc-4.8.5/freetype-2.7-mhhi2pufcglnyisabx7ha4ylcuyqmf3u/lib/libfreetype.so

 FREETYPE_INCLUDE_DIRS: /cluster/apps/gcc-4.8.5/freetype-2.7-mhhi2pufcglnyisabx7ha4ylcuyqmf3u/include/freetype2

 Boost_LIBRARIES:   /cluster/apps/gcc-4.8.5/boost-1.64.0-unobzlo4mdmdkthumilwexlles6eral4/lib/libboost_python-mt.so

 Boost_INCLUDE_DIR: /cluster/apps/gcc-4.8.5/boost-1.64.0-unobzlo4mdmdkthumilwexlles6eral4/include

I guess you can't provide any support since building EMAN2 without using Conda is not supported any more, but I would like to document this issues for other people also trying to build EMAN2 without Conda.

I will provide an update if I can resolve this problem

Best regards

Sam

@sludtke42
Copy link
Member

sludtke42 commented Jul 2, 2019 via email

@samfux84
Copy link
Author

samfux84 commented Jul 2, 2019

Hi Steven,

Thank you for your reply.

Now after installing all dependencies without Conda (for instance installing PyQT5 for Python 2.7.14) I start to get a better understanding why you switched to Conda. As I am quite experienced setting up software on a HPC cluster, I wanted to take the challenge getting EMAN2 installed without using Conda (which worked quite well for all dependencies). Also because I am always trying to use already installed software instead of making redundant installations. Especially for OpenMPI I prefer to use the version that we installed, because it was compiled with support for our batch system (LSF).

Thank you for the hint of looking at an older version of CMakeLists.txt.

Currently, the modification that I did was replacing

# Set EMAN_PREFIX
if("$ENV{CONDA_BUILD_STATE}" STREQUAL "BUILD" )
        message("ENV{CONDA_BUILD_STATE}: $ENV{CONDA_BUILD_STATE}")
        if(NOT WIN32)
                set(EMAN_PREFIX $ENV{PREFIX})
        else()
                set(EMAN_PREFIX $ENV{LIBRARY_PREFIX})
        endif()
else()
        find_package(Conda REQUIRED)

        if(CONDA_PREFIX)
                if(NOT WIN32)
                        set(EMAN_PREFIX ${CONDA_PREFIX})
                else()
                        set(EMAN_PREFIX ${CONDA_PREFIX}/Library)
                endif()
        endif()
endif()

set(EMAN_PREFIX_INC      ${EMAN_PREFIX}/include)
set(EMAN_PREFIX_LIB      ${EMAN_PREFIX}/lib)
set(CMAKE_INSTALL_PREFIX ${EMAN_PREFIX} CACHE PATH "installation prefix" FORCE)
set(CMAKE_PREFIX_PATH    ${EMAN_PREFIX} ${EMAN_PREFIX}/..)
message_var(CMAKE_PREFIX_PATH)

with

set(CMAKE_INSTALL_PREFIX "/cluster/apps/eman2/2.3/x86_64")
set(EMAN_PREFIX          ${CMAKE_INSTALL_PREFIX})
set(EMAN_PREFIX_INC      ${EMAN_PREFIX}/include)
set(EMAN_PREFIX_LIB      ${EMAN_PREFIX}/lib)
set(CMAKE_PREFIX_PATH    ${EMAN_PREFIX} ${EMAN_PREFIX}/..)
message_var(CMAKE_PREFIX_PATH)

I will have a look at an older CMakeLists.txt file and try to resolve the issue. If I can't find a solution until the end of this week, then I will go with the Conda setup.

Thank you for your help.

Best regards

Sam

@shadowwalkersb
Copy link
Member

shadowwalkersb commented Jul 2, 2019

If you specify the necessary variables to point to the right libraries and include directories, you shouldn't need conda related stuff in cmake. I don't think the problem you are seeing is conda related. Looks like with cmake 3.10, findFreetype defines imported targets which are not supposed to be modified. I am not sure why I am not seeing the same errors when I use newer cmake versions, but I believe, your problem can be fixed by just removing the whole if-block setting the Freetype target,

if(Freetype_FOUND AND NOT TARGET Freetype)
add_library(Freetype INTERFACE)
add_library(Freetype::Freetype ALIAS Freetype)
set_target_properties(Freetype
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${FREETYPE_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FREETYPE_LIBRARIES}"
)
endif()
. So, Freetype.cmake becomes

find_package(Freetype REQUIRED)

message("FREETYPE_LIBRARIES:    ${FREETYPE_LIBRARIES}")
message("FREETYPE_INCLUDE_DIRS: ${FREETYPE_INCLUDE_DIRS}")

I don't know, if other targets will cause similar problems after fixing this.

Hope this helps.

@shadowwalkersb
Copy link
Member

Or, if you can, use cmake 3.9, maybe.

@samfux84
Copy link
Author

I could fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants