EDIT: I have found the reason why the plugins library is undefined: it simply fails to compile. That said, i still am having an hard time finding the root cause.
The CMakeError.log outputs this:
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/gamemaid/wow/dev/TrinityCore/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec4168097918/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec4168097918.dir/build.make CMakeFiles/cmTryCompileExec4168097918.dir/build
make[1]: Entering directory '/home/gamemaid/wow/dev/TrinityCore/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/gamemaid/wow/dev/TrinityCore/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec4168097918.dir/CheckSymbolExists.c.o
/usr/bin/cc -std=gnu99 -W -Wall -Wextra -Winit-self -Winvalid-pch -Wfatal-errors -o CMakeFiles/cmTryCompileExec4168097918.dir/CheckSymbolExists.c.o -c /home/gamemaid/wow/dev/TrinityCore/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec4168097918
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec4168097918.dir/link.txt --verbose=1
/usr/bin/cc -std=gnu99 -W -Wall -Wextra -Winit-self -Winvalid-pch -Wfatal-errors CMakeFiles/cmTryCompileExec4168097918.dir/CheckSymbolExists.c.o -o cmTryCompileExec4168097918 -rdynamic
CMakeFiles/cmTryCompileExec4168097918.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x16): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTryCompileExec4168097918.dir/build.make:88: recipe for target 'cmTryCompileExec4168097918' failed
make[1]: *** [cmTryCompileExec4168097918] Error 1
make[1]: Leaving directory '/home/gamemaid/wow/dev/TrinityCore/build/CMakeFiles/CMakeTmp'
Makefile:118: recipe for target 'cmTryCompileExec4168097918/fast' failed
make: *** [cmTryCompileExec4168097918/fast] Error 2
File /home/gamemaid/wow/dev/TrinityCore/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
}
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/gamemaid/wow/dev/TrinityCore/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec1876865723/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec1876865723.dir/build.make CMakeFiles/cmTryCompileExec1876865723.dir/build
make[1]: Entering directory '/home/gamemaid/wow/dev/TrinityCore/build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/gamemaid/wow/dev/TrinityCore/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec1876865723.dir/CheckFunctionExists.c.o
/usr/bin/cc -std=gnu99 -W -Wall -Wextra -Winit-self -Winvalid-pch -Wfatal-errors -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec1876865723.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.0/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec1876865723
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec1876865723.dir/link.txt --verbose=1
/usr/bin/cc -std=gnu99 -W -Wall -Wextra -Winit-self -Winvalid-pch -Wfatal-errors -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec1876865723.dir/CheckFunctionExists.c.o -o cmTryCompileExec1876865723 -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTryCompileExec1876865723.dir/build.make:88: recipe for target 'cmTryCompileExec1876865723' failed
Everything below this line is left for backlog and is no longer part of the issue.
I have been beating my head on this CMake code for days, to no avail. For some reason, by the time i call it on
if (USE_COREPCH) add_cxx_pch(plugins ${plugins_STAT_PCH_HDR} ${plugins_STAT_PCH_SRC}) endif()
the variable "plugins" is undefined, and the method fails. I can't seem to understand why this is the case, since i clearly define it with the add_library method.
CollectSourceFiles( ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE_SOURCES # Exclude ${CMAKE_CURRENT_SOURCE_DIR}/pch) if (USE_COREPCH) set(plugins_STAT_PCH_HDR pch/pch.h) set(plugins_STAT_PCH_SRC pch/pch.cpp) endif () GroupSources(${CMAKE_CURRENT_SOURCE_DIR}) add_library(plugins STATIC ${plugins_STAT_PCH_SRC} ${PRIVATE_SOURCES} ) CollectIncludeDirectories( ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC_INCLUDES # Exclude ${CMAKE_CURRENT_SOURCE_DIR}/pch) target_include_directories(plugins PUBLIC ${PUBLIC_INCLUDES} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) add_dependencies(plugins revision_data.h) if( WIN32 ) if ( MSVC ) add_custom_command(TARGET plugins POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/playerbot/aiplayerbot.conf.dist.in
${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/ ) add_custom_command(TARGET plugins POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/ahbot/ahbot.conf.dist.in ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/ ) elseif ( MINGW )
add_custom_command(TARGET plugins POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}playerbot/aiplayerbot.conf.dist.in
${CMAKE_BINARY_DIR}/bin/ ) add_custom_command(TARGET plugins POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}ahbot/ahbot.conf.dist.in ${CMAKE_BINARY_DIR}/bin/ ) endif() endif()
if( UNIX ) install(TARGETS plugins DESTINATION bin) install(FILES playerbot/aiplayerbot.conf.dist.in DESTINATION ${CONF_DIR}) install(FILES ahbot/ahbot.conf.dist.in DESTINATION ${CONF_DIR}) elseif( WIN32 ) install(TARGETS plugins DESTINATION "${CMAKE_INSTALL_PREFIX}") install(FILES playerbot/aiplayerbot.conf.dist.in DESTINATION "${CMAKE_INSTALL_PREFIX}") install(FILES ahbot/ahbot.conf.dist.in DESTINATION "${CMAKE_INSTALL_PREFIX}") endif() # DEBUG CODE if (DEFINED plugins) MESSAGE("PLUGINS IS DEFINED") endif() MESSAGE(${plugins_STAT_PCH_SRC}) MESSAGE(${CMAKE_CURRENT_SOURCE_DIR}) MESSAGE(${PRIVATE_SOURCES}) # DEBUG if (USE_COREPCH) add_cxx_pch(plugins ${plugins_STAT_PCH_HDR} ${plugins_STAT_PCH_SRC}) endif()
EDIT: I have confirmed that immediately after the add_library(plugins [..]) call plugins is still undefined. This is really weird and i have no idea what to do about it.