CMake: не может создать цель, потому что другая цель с таким именем уже существует - PullRequest
0 голосов
/ 30 сентября 2018

Я пытаюсь установить plexe-sumo с помощью cmake.Я следовал учебному пособию на plexe.car2x.org и вот результаты:

-- CMAKE_BUILD_TYPE: Release
-- CMAKE_BINARY_DIR: /home/cc/src/plexe-sumo/build-release
-- CMAKE_SOURCE_DIR: /home/cc/src/plexe-sumo
-- 
-- Platform: 
--     Host: Linux4.15.0-34-genericx86_64
--     CMake: 3.12.2
--     CMake generator: Unix Makefiles
--     CMake build tool: /usr/bin/make
-- 
-- Found Proj: /usr/lib/x86_64-linux-gnu/libproj.so
CMake Error at /usr/local/share/cmake-3.12/Modules/UseSWIG.cmake:627 (add_custom_target):
  add_custom_target cannot create target "libsumo_swig_compilation" because
  another target with the same name already exists.  The existing target is a
  custom target created in source directory
  "/home/cc/src/plexe-sumo/src/libsumo".  See documentation for policy
  CMP0002 for more details.
Call Stack (most recent call first):
  src/libsumo/CMakeLists.txt:39 (SWIG_ADD_LIBRARY)


-- Enabled features: Linux-4.15.0-34-generic Proj GUI GDAL OSG GL2PS SWIG
-- Configuring incomplete, errors occurred!

Нет файла с именем 'libsumo_swig_compilation' в папке "/ home / cc / src / plexe-sumo / src / libsumo".

Затем я проверил файл журнала ошибок, но показанные ошибки касаются pthread, говоря «неопределенная ссылка на pthread_creat» и «не удается найти -lpthreads».На самом деле моя библиотека pthread установлена ​​по адресу 'libc6: /lib/x86_64-linux-gnu/libpthread.so.0'.

Так что мне было интересно, в чем именно заключается проблема и как ее решить.Я использую виртуальную машину с Ubuntu 16. Я ценю вашу помощь!

Ниже приведен файл журнала ошибок:

Determining if the pthread_create exist failed with the following output:
Change Dir: /home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_050d5/fast"
/usr/bin/make -f CMakeFiles/cmTC_050d5.dir/build.make CMakeFiles/cmTC_050d5.dir/build
make[1]: Entering directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o
/usr/bin/cc   -Wall -pedantic -Wextra    -o CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o   -c /home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function ‘main’:
/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:11: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
   return ((int*)(&pthread_create))[argc];
           ^
Linking C executable cmTC_050d5
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_050d5.dir/link.txt --verbose=1
/usr/bin/cc  -Wall -pedantic -Wextra     -rdynamic CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o  -o cmTC_050d5 
CMakeFiles/cmTC_050d5.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_050d5.dir/build.make:86: recipe for target 'cmTC_050d5' failed
make[1]: *** [cmTC_050d5] Error 1
make[1]: Leaving directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_050d5/fast' failed
make: *** [cmTC_050d5/fast] Error 2

File /home/cc/src/plexe-sumo/build-release/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
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_9f654/fast"
/usr/bin/make -f CMakeFiles/cmTC_9f654.dir/build.make CMakeFiles/cmTC_9f654.dir/build
make[1]: Entering directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o
/usr/bin/cc   -Wall -pedantic -Wextra -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o   -c /usr/local/share/cmake-3.12/Modules/CheckFunctionExists.c
Linking C executable cmTC_9f654
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9f654.dir/link.txt --verbose=1
/usr/bin/cc  -Wall -pedantic -Wextra -DCHECK_FUNCTION_EXISTS=pthread_create    -rdynamic CMakeFiles/cmTC_9f654.dir/CheckFunctionExists.c.o  -o cmTC_9f654 -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_9f654.dir/build.make:86: recipe for target 'cmTC_9f654' failed
make[1]: *** [cmTC_9f654] Error 1
make[1]: Leaving directory '/home/cc/src/plexe-sumo/build-release/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_9f654/fast' failed
make: *** [cmTC_9f654/fast] Error 2

1 Ответ

0 голосов
/ 30 сентября 2018

Я предполагаю, что это действительно поведение, которое показывает только новый cmake.Вы можете попробовать переименовать все ссылки на libsumo в java-части CMakeLists.txt или просто использовать CMakeLists главной строки sumo здесь: https://github.com/eclipse/sumo/blob/master/src/libsumo/CMakeLists.txt

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...