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

Compile error: install TARGETS given no ARCHIVE DESTINATION for static library target "randomx". #157

Closed
ehoffman2 opened this issue Nov 15, 2019 · 6 comments

Comments

@ehoffman2
Copy link

Trying to compile under Ubuntu 18.04, using cmake 3.10.2, gcc 7.4.0

> cmake -DARCH=native ..
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting default build type: Release
-- Performing Test _march=native_cxx
-- Performing Test _march=native_cxx - Success
-- Setting CXX flag -march=native
-- Performing Test _march=native_c
-- Performing Test _march=native_c - Success
-- Setting C flag -march=native
CMake Error at CMakeLists.txt:161 (install):
  install TARGETS given no ARCHIVE DESTINATION for static library target
  "randomx".


-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Performing Test HAVE_CXX_ATOMICS
-- Performing Test HAVE_CXX_ATOMICS - Success
-- Configuring incomplete, errors occurred!
See also "/home/ehoffman/work/RandomX/build/CMakeFiles/CMakeOutput.log".
See also "/home/ehoffman/work/RandomX/build/CMakeFiles/CMakeError.log".

Output of CmakeError.log:

Determining if the pthread_create exist failed with the following output:
Change Dir: /home/ehoffman/work/RandomX/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_03eae/fast"
/usr/bin/make -f CMakeFiles/cmTC_03eae.dir/build.make CMakeFiles/cmTC_03eae.dir/build
make[1]: Entering directory '/home/ehoffman/work/RandomX/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_03eae.dir/CheckSymbolExists.c.o
/usr/bin/cc   -march=native    -o CMakeFiles/cmTC_03eae.dir/CheckSymbolExists.c.o   -c /home/ehoffman/work/RandomX/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_03eae
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_03eae.dir/link.txt --verbose=1
/usr/bin/cc  -march=native     -rdynamic CMakeFiles/cmTC_03eae.dir/CheckSymbolExists.c.o  -o cmTC_03eae 
CMakeFiles/cmTC_03eae.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x1b): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_03eae.dir/build.make:97: recipe for target 'cmTC_03eae' failed
make[1]: *** [cmTC_03eae] Error 1
make[1]: Leaving directory '/home/ehoffman/work/RandomX/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_03eae/fast' failed
make: *** [cmTC_03eae/fast] Error 2

File /home/ehoffman/work/RandomX/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[argc];
#else
  (void)argc;
  return 0;
#endif
}
@ehoffman2
Copy link
Author

I reverted to e43267f and it works fine, do this has to do with 66c0390 that was committed today...

Regards,
Eric Hoffman

@tevador
Copy link
Owner

tevador commented Nov 15, 2019

Thanks for reporting. I tested with cmake 3.14.4, where it works.

I will revert the PR.

@bjacquin

@ehoffman2
Copy link
Author

Actually, the doc say that CMAKE_INSTALL_LIBDIR get defined if you include GNUInstallDirs in the CMake project.

Ex:

add_library(mylib STATIC ...)
set_target_properties(mylib PROPERTIES PUBLIC_HEADER mylib.h)
include(GNUInstallDirs)
install(TARGETS mylib
        PUBLIC_HEADER
          DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/myproj
)

https://cmake.org/cmake/help/latest/command/install.html

It seems that one should not rely on those pre-defined variables unless you include GNUInstallDirs.

Regards,
Eric

@ehoffman2
Copy link
Author

Just tested, I added, bellow the cmake_minimum_required clause,

include(GNUInstallDirs)

Keeping the ${CMAKE_INSTALL_LIBDIR}, and it compiled.

Regards,
Eric

@tevador
Copy link
Owner

tevador commented Nov 19, 2019

Please check #160

@bjacquin
Copy link
Contributor

Good spot, indeed this was tested only on Gentoo while my knowledge of CMake are very limited

@tevador tevador closed this as completed Nov 22, 2019
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