Unable to Link Libraries to Target? - c

I have the following CMakeLists.txt, trying to build my software on Windows with MinGW-w64:
#
# Initial CMake and project setup
#
# Required CMake version (ExternalProject)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
INCLUDE(ExternalProject)
SET(PROJECT_NAME Khronos)
PROJECT(${PROJECT_NAME})
# Set software version
SET(APPLICATION_VERSION_MAJOR "0")
SET(APPLICATION_VERSION_MINOR "4")
SET(APPLICATION_VERSION_PATCH "0")
SET(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/library-build)
#
# Setup compiler flags
#
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE Release FORCE)
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -std=gnu11 -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -std=gnu11 -O3")
if (GCC_VERSION VERSION_GREATER "4.8")
elsif (GCC_VERSION VERSION_GREATER "4.1.2")
SET (GCC_COMMON_WARNING_FLAGS "-pedantic -Wall -Wextra -Wconversion -Wfloat-equal -Wformat=2 -Winit-self -Winline -Winvalid-pch -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstack-protector -Wstrict-null-sentinel -Wswitch-default -Wswitch-enum")
SET (GCC_COMMON_WARNING_FLAGS "${GCC_COMMON_WARNING_FLAGS} -Wno-unused-parameter")
SET (GCC_CXX_WARNING_FLAGS "-Wctor-dtor-privacy")
else ()
SET(GCC_COMMON_WARNING_FLAGS "-pedantic -Wall -Wextra -Wconversion -Wfloat-equal -Wformat=2 -Winit-self -Winline -Winvalid-pch -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstack-protector -Wstrict-null-sentinel -Wswitch-default -Wswitch-enum")
SET(GCC_COMMON_WARNING_FLAGS "${GCC_COMMON_WARNING_FLAGS} -Wno-unused-parameter")
SET(GCC_CXX_WARNING_FLAGS "-Wctor-dtor-privacy")
endif ()
#
# Find Doxygen for documentation
#
# add a target to generate API documentation with Doxygen
FIND_PACKAGE(Doxygen)
if (DOXYGEN_FOUND)
ADD_CUSTOM_TARGET(DOC
${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif ()
#
# Find/install dependencies
#
IF(WIN32)
INCLUDE(${CMAKE_MODULE_PATH}/Win32-ExternalProjects.txt)
ELSE(UNIX)
INCLUDE(${CMAKE_MODULE_PATH}/Unix-ExternalProjects.txt)
ENDIF()
#
# Final project settings
#
INCLUDE_DIRECTORIES(include)
ADD_SUBDIRECTORY(src)
ADD_EXECUTABLE(${PROJECT_NAME}
$<TARGET_OBJECTS:audio>
$<TARGET_OBJECTS:util>
$<TARGET_OBJECTS:main>
)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIBS})
if (DEPENDENCIES)
MESSAGE (STATUS "Any missing dependencies will be downloaded upon running \"make\"")
ADD_DEPENDENCIES(${PROJECT_NAME} ${DEPENDENCIES})
endif ()
I'm able to compile everything, but I'm having trouble linking the executable to the libraries:
"C:\Program Files (x86)\CMake\bin\cmake.exe" -HC:\Users\syb0rg\Downloads\Khronos -BC:\Users\syb0rg\Downloads\Khronos\build --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_start C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\progress.marks
make -f CMakeFiles\Makefile2 all
make[1]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\sphinxbase.dir\build.make CMakeFiles/sphinxbase.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\sphinxbase.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\sphinxbase.dir\build.make CMakeFiles/sphinxbase.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `CMakeFiles/sphinxbase.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 17%] Built target sphinxbase
make -f CMakeFiles\LibSndFile.dir\build.make CMakeFiles/LibSndFile.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\LibSndFile.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\LibSndFile.dir\build.make CMakeFiles/LibSndFile.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `CMakeFiles/LibSndFile.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 35%] Built target LibSndFile
make -f CMakeFiles\pocketsphinx.dir\build.make CMakeFiles/pocketsphinx.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\pocketsphinx.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\pocketsphinx.dir\build.make CMakeFiles/pocketsphinx.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `CMakeFiles/pocketsphinx.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 53%] Built target pocketsphinx
make -f CMakeFiles\PortAudio.dir\build.make CMakeFiles/PortAudio.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\PortAudio.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\PortAudio.dir\build.make CMakeFiles/PortAudio.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `CMakeFiles/PortAudio.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 71%] Built target PortAudio
make -f src\audio\CMakeFiles\audio.dir\build.make src/audio/CMakeFiles/audio.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\src\audio C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\src\audio C:\Users\syb0rg\Downloads\Khronos\build\src\audio\CMakeFiles\audio.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f src\audio\CMakeFiles\audio.dir\build.make src/audio/CMakeFiles/audio.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `src/audio/CMakeFiles/audio.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 73%] Built target audio
make -f src\util\CMakeFiles\util.dir\build.make src/util/CMakeFiles/util.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\src\util C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\src\util C:\Users\syb0rg\Downloads\Khronos\build\src\util\CMakeFiles\util.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f src\util\CMakeFiles\util.dir\build.make src/util/CMakeFiles/util.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `src/util/CMakeFiles/util.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 75%] Built target util
make -f src\CMakeFiles\main.dir\build.make src/CMakeFiles/main.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\src C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\src C:\Users\syb0rg\Downloads\Khronos\build\src\CMakeFiles\main.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f src\CMakeFiles\main.dir\build.make src/CMakeFiles/main.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `src/CMakeFiles/main.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 80%] Built target main
make -f CMakeFiles\tritium.dir\build.make CMakeFiles/tritium.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\tritium.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\tritium.dir\build.make CMakeFiles/tritium.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[2]: Nothing to be done for `CMakeFiles/tritium.dir/build'.
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
[ 97%] Built target tritium
make -f CMakeFiles\Khronos.dir\build.make CMakeFiles/Khronos.dir/depend
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build C:\Users\syb0rg\Downloads\Khronos\build\CMakeFiles\Khronos.dir\DependInfo.cmake --color=
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make -f CMakeFiles\Khronos.dir\build.make CMakeFiles/Khronos.dir/build
make[2]: Entering directory `C:/Users/syb0rg/Downloads/Khronos/build'
[100%] Linking C executable Khronos.exe
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\Khronos.dir\link.txt --verbose=1
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E remove -f CMakeFiles\Khronos.dir/objects.a
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\ar.exe cr CMakeFiles\Khronos.dir/objects.a #CMakeFiles\Khronos.dir\objects1.rsp
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\gcc.exe -Wl,--whole-archive CMakeFiles\Khronos.dir/objects.a -Wl,--no-whole-archive -o Khronos.exe -Wl,--out-implib,libKhronos.dll.a -Wl,--major-image-version,0,--minor-image-version,0 #CMakeFiles\Khronos.dir\linklibs.rsp
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0xd2): undefined reference to `ps_start_utt'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x109): undefined reference to `ps_process_raw'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x115): undefined reference to `ps_get_in_speech'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x161): undefined reference to `ps_end_utt'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x172): undefined reference to `ps_get_hyp'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x185): undefined reference to `ps_start_utt'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x1ce): undefined reference to `ps_end_utt'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x1e8): undefined reference to `ps_get_hyp'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x24b): undefined reference to `getPathFromDescriptor'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x61c): undefined reference to `err_set_logfp'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x626): undefined reference to `err_set_debug_level'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x678): undefined reference to `ps_args'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x6d7): undefined reference to `cmd_ln_init'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x71f): undefined reference to `ps_init'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x7fb): undefined reference to `ps_free'
CMakeFiles\Khronos.dir/objects.a(main.c.obj):main.c:(.text+0x807): undefined reference to `cmd_ln_free_r'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [Khronos.exe] Error 1
make[2]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make[1]: *** [CMakeFiles/Khronos.dir/all] Error 2
make[1]: Leaving directory `C:/Users/syb0rg/Downloads/Khronos/build'
make: *** [all] Error 2
Here's the ${LIBS} output from message() (in a more human readable form):
C:/Users/syb0rg/Downloads/Khronos/lib/sphinxbase/bin/Debug/Win32/sphinxbase.dll
C:/Users/syb0rg/Downloads/Khronos/lib/pocketsphinx/bin/Debug/Win32/pocketsphinx.dll
C:/Users/syb0rg/Downloads/Khronos/lib/PortAudio/libportaudio_x86.dll
C:/Users/syb0rg/Downloads/Khronos/lib/LibSndFile/libsndfile.dll
C:/Users/syb0rg/Downloads/Khronos/lib/tritium/libtritium.a
For reference, ${LIBS} is set here:
FIND_PACKAGE(sphinxbase)
if (${SPHINXBASE_FOUND})
INCLUDE_DIRECTORIES(${SPHINXBASE_INCLUDE_DIR}/sphinxbase/)
else ()
ExternalProject_Add(
sphinxbase
GIT_REPOSITORY "https://github.com/cmusphinx/sphinxbase.git"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/sphinxbase
CONFIGURE_COMMAND ""
BUILD_COMMAND msbuild sphinxbase.sln /p:PlatformToolset=v140
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(sphinxbase SOURCE_DIR)
ExternalProject_Get_Property(sphinxbase BINARY_DIR)
SET(SPHINXBASE_SOURCE_DIR ${SOURCE_DIR})
SET(SPHINXBASE_BINARY_DIR ${BINARY_DIR})
SET(SPHINXBASE_LIBRARIES ${SPHINXBASE_BINARY_DIR}/bin/Debug/Win32/sphinxbase.dll)
SET(DEPENDENCIES ${DEPENDENCIES} sphinxbase)
INCLUDE_DIRECTORIES(${SPHINXBASE_SOURCE_DIR}/include/win32)
INCLUDE_DIRECTORIES(${SPHINXBASE_SOURCE_DIR}/include)
endif ()
SET(LIBS ${LIBS} ${SPHINXBASE_LIBRARIES})
FIND_PACKAGE(pocketsphinx)
if (${POCKETSPHINX_FOUND})
INCLUDE_DIRECTORIES(${POCKETSPHINX_INCLUDE_DIR}/pocketsphinx/)
add_definitions( -DMODELDIR="/usr/local/share/pocketsphinx/model") # more portable?
else ()
ExternalProject_Add(
pocketsphinx
DEPENDS sphinxbase
GIT_REPOSITORY "https://github.com/cmusphinx/pocketsphinx.git"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/pocketsphinx
CONFIGURE_COMMAND ""
BUILD_COMMAND msbuild pocketsphinx.sln /p:PlatformToolset=v140
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(pocketsphinx SOURCE_DIR)
ExternalProject_Get_Property(pocketsphinx BINARY_DIR)
SET(POCKETSPHINX_SOURCE_DIR ${SOURCE_DIR})
SET(POCKETSPHINX_BINARY_DIR ${BINARY_DIR})
SET(POCKETSPHINX_LIBRARIES ${POCKETSPHINX_BINARY_DIR}/bin/Debug/Win32/pocketsphinx.dll)
SET(DEPENDENCIES ${DEPENDENCIES} pocketsphinx)
INCLUDE_DIRECTORIES(${POCKETSPHINX_SOURCE_DIR}/include/)
add_definitions(-DMODELDIR="${POCKETSPHINX_BINARY_DIR}/model")
endif ()
SET(LIBS ${LIBS} ${POCKETSPHINX_LIBRARIES})
FIND_PACKAGE(PortAudio)
if (${PORTAUDIO_FOUND})
INCLUDE_DIRECTORIES(${PORTAUDIO_INCLUDE_DIRS})
else ()
ExternalProject_Add(
PortAudio
GIT_REPOSITORY "https://github.com/syb0rg/PortAudio2.git"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/PortAudio
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(PortAudio SOURCE_DIR)
ExternalProject_Get_Property(PortAudio BINARY_DIR)
SET(PORTAUDIO_SOURCE_DIR ${SOURCE_DIR})
SET(PORTAUDIO_BINARY_DIR ${BINARY_DIR})
SET(PORTAUDIO_LIBRARIES ${PORTAUDIO_BINARY_DIR}/libportaudio_x86.dll)
SET(DEPENDENCIES ${DEPENDENCIES} PortAudio)
INCLUDE_DIRECTORIES(${PORTAUDIO_SOURCE_DIR}/include)
endif ()
SET(LIBS ${LIBS} ${PORTAUDIO_LIBRARIES})
FIND_PACKAGE(LibSndFile)
if(${LIBSNDFILE_FOUND})
INCLUDE_DIRECTORIES(${LIBSNDFILE_INCLUDE_DIRS})
else ()
ExternalProject_Add(
LibSndFile
GIT_REPOSITORY "https://github.com/syb0rg/libsndfile.git"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/LibSndFile
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(LibSndFile SOURCE_DIR)
ExternalProject_Get_Property(LibSndFile BINARY_DIR)
SET(LIBSNDFILE_SOURCE_DIR ${SOURCE_DIR}/src)
SET(LIBSNDFILE_BINARY_DIR ${BINARY_DIR})
SET(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_BINARY_DIR}/libsndfile.dll)
SET(DEPENDENCIES ${DEPENDENCIES} LibSndFile)
INCLUDE_DIRECTORIES(${LIBSNDFILE_SOURCE_DIR})
endif ()
SET(LIBS ${LIBS} ${LIBSNDFILE_LIBRARIES})
FIND_PACKAGE(tritium)
if (${TRITIUM_FOUND})
INCLUDE_DIRECTORIES(${TRITIUM_INCLUDE_DIR}/)
else ()
ExternalProject_Add(
tritium
GIT_REPOSITORY "https://github.com/syb0rg/tritium.git"
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/tritium
UPDATE_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE ON
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
)
ExternalProject_Get_Property(tritium SOURCE_DIR)
ExternalProject_Get_Property(tritium BINARY_DIR)
SET(TRITIUM_SOURCE_DIR ${SOURCE_DIR})
SET(TRITIUM_BINARY_DIR ${BINARY_DIR})
SET(TRITIUM_LIBRARIES ${TRITIUM_BINARY_DIR}/libtritium.a)
SET(DEPENDENCIES ${DEPENDENCIES} tritium)
INCLUDE_DIRECTORIES(${TRITIUM_SOURCE_DIR}/include)
endif ()
SET(LIBS ${LIBS} ${TRITIUM_LIBRARIES})
All of these libraries exist at the specified location. Any suggestions?

undefined reference to clearly stated you do not provide required object file/library with this (exported!) function to linker. There are two major causes:
You didn't pass this library to linker command line or didn't pass right search path (-L...) to it - check twice the resulting command line, make VERBOSE=1 will show more verbose output.
Path is correct, but file/function itself is invalid - you may compile library for different CPU architecture (e.g. trying to use x86 library when targeting x86_64). Also check function marked as exportable (in most cases it is the problem when using MSVC compiler, but you can hide functions with GCC/MinGW too). And do not forgot to check file is not zero-length :)

Can you try this:
set(CMAKE_BUILD_TYPE CACHE Release FORCE)
ref: https://cmake.org/cmake/help/v2.8.8/cmake.html#variable:CMAKE_CFG_INTDIR
search for : initial-cache

Related

While building GCC 8.5.0: "error: `CC' has changed since the previous run"

I'm building GCC 8.5.0 on a Devuan Chimaera GNU/Linux system (using GCC 10). I've configured with ./configure --disable-gnat, then ran make. At some point, I get:
echo timestamp > s-selftest-c
rm gcc.pod
make[3]: Leaving directory '/usr/local/src/gcc-8.5.0/host-x86_64-pc-linux-gnu/gcc'
Checking multilib configuration for libgcc...
Configuring stage 1 in x86_64-pc-linux-gnu/libgcc
configure: loading cache ./config.cache
configure: error: `CC' has changed since the previous run:
configure: former value: `/usr/local/src/gcc-8.5.0/host-x86_64-pc-linux-gnu/gcc/xgcc -B/usr/local/src/gcc-8.5.0/host-x86_64-pc-linux-gnu/gcc/ -B/opt/gcc-8.5.0/x86_64-pc-linux-gnu/bin/ -B/opt/gcc-8.5.0/x86_64-pc-linux-gnu/lib/ -isystem /opt/gcc-8.5.0/x86_64-pc-linux-gnu/include -isystem /opt/gcc-8.5.0/x86_64-pc-linux-gnu/sys-include '
configure: current value: `/usr/local/src/gcc-8.5.0/host-x86_64-pc-linux-gnu/gcc/xgcc -B/usr/local/src/gcc-8.5.0/host-x86_64-pc-linux-gnu/gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/ -B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem /usr/local/x86_64-pc-linux-gnu/include -isystem /usr/local/x86_64-pc-linux-gnu/sys-include '
configure: error: in `/usr/local/src/gcc-8.5.0/x86_64-pc-linux-gnu/libgcc':
configure: error: changes in the environment can compromise the build
configure: error: run `make distclean' and/or `rm ./config.cache' and start over
make[2]: *** [Makefile:18716: configure-stage1-target-libgcc] Error 1
make[2]: Leaving directory '/usr/local/src/gcc-8.5.0'
make[1]: *** [Makefile:24352: stage1-bubble] Error 2
make[1]: Leaving directory '/usr/local/src/gcc-8.5.0'
make: *** [Makefile:945: all] Error 2
Why is this happening? I tried make distclean and repeating the process, but it didn't help.
GCC build prerequisites ...
# apt install g++ autoconf libtool gawk flex bison binutils-dev libelf-dev texinfo zlib1g-dev
Example configuring gcc-8.5.0
tar xvf gcc-8.5.0.tar.xz
cd gcc-8.5.0/
tar xvf mpfr-4.0.2.tar.xz && mv -v mpfr-4.0.2 mpfr
tar xvf gmp-6.1.2.tar.xz && mv -v gmp-6.1.2 gmp
tar xvf mpc-1.1.0.tar.gz && mv -v mpc-1.1.0 mpc
cd ../
mkdir build-gcc850
cd build-gcc850/
export CC=gcc73 CXX=g++73 && \
../gcc-8.5.0/configure --prefix=/usr/local/gcc85 \
--program-suffix=85 --enable-languages=c,c++,fortran \
--disable-multilib --disable-libstdcxx-pch --with-system-zlib

Cannot statically use an installed library

I am trying to statically link and use a library that I installed in my system, but even when at compile/link time I do not get errors. At runtime I get them.
Getting the library
I downloaded and installed libpfm4. I ran make sudo make install:
And got this:
installing in /usr/local
make[1]: Entering directory '/home/username/libpfm4/lib'
building: libpfm.a libpfm.so.4.11.1
mkdir -p /usr/local/lib
install -m 644 libpfm.a /usr/local/lib
install libpfm.so.4.11.1 /usr/local/lib
cd /usr/local/lib; ln -sf libpfm.so.4.11.1 libpfm.so.4
cd /usr/local/lib; ln -sf libpfm.so.4.11.1 libpfm.so
ldconfig
make[1]: Leaving directory '/home/username/libpfm4/lib'
make[1]: Entering directory '/home/username/libpfm4/tests'
make[1]: Nothing to be done for 'install'.
make[1]: Leaving directory '/home/username/libpfm4/tests'
make[1]: Entering directory '/home/username/libpfm4/examples'
make[1]: Nothing to be done for 'install'.
make[1]: Leaving directory '/home/username/libpfm4/examples'
make[1]: Entering directory '/home/username/libpfm4/perf_examples'
make[1]: Nothing to be done for 'install'.
make[1]: Leaving directory '/home/username/libpfm4/perf_examples'
make[1]: Entering directory '/home/username/libpfm4/include'
mkdir -p /usr/local/include/perfmon
install -m 644 perfmon/pfmlib.h perfmon/perf_event.h perfmon/pfmlib_perf_event.h /usr/local/include/perfmon
make[1]: Leaving directory '/home/username/libpfm4/include'
make[1]: Entering directory '/home/username/libpfm4/docs'
mkdir -p /usr/local/share/man/man3
( cd man3; install -m 644 libpfm.3 pfm_find_event.3 pfm_get_event_attr_info.3 pfm_get_event_info.3 pfm_get_event_encoding.3 pfm_get_event_next.3 pfm_get_pmu_info.3 pfm_get_os_event_encoding.3 pfm_get_version.3 pfm_initialize.3 pfm_terminate.3 pfm_strerror.3 libpfm_intel_core.3 libpfm_intel_x86_arch.3 libpfm_amd64.3 libpfm_amd64_k7.3 libpfm_amd64_k8.3 libpfm_amd64_fam10h.3 libpfm_amd64_fam15h.3 libpfm_amd64_fam16h.3 libpfm_amd64_fam17h.3 libpfm_amd64_fam17h_zen2.3 libpfm_amd64_fam19h_zen3.3 libpfm_amd64_fam19h_zen3_l3.3 libpfm_intel_atom.3 libpfm_intel_nhm.3 libpfm_intel_nhm_unc.3 libpfm_intel_wsm.3 libpfm_intel_wsm_unc.3 libpfm_intel_snb.3 libpfm_intel_snb_unc.3 libpfm_intel_ivb.3 libpfm_intel_ivb_unc.3 libpfm_intel_hsw.3 libpfm_intel_bdw.3 libpfm_intel_rapl.3 libpfm_intel_slm.3 libpfm_intel_tmt.3 libpfm_intel_skl.3 libpfm_intel_icl.3 libpfm_intel_glm.3 libpfm_intel_knl.3 libpfm_intel_knm.3 libpfm_intel_snbep_unc_cbo.3 libpfm_intel_snbep_unc_ha.3 libpfm_intel_snbep_unc_imc.3 libpfm_intel_snbep_unc_pcu.3 libpfm_intel_snbep_unc_qpi.3 libpfm_intel_snbep_unc_ubo.3 libpfm_intel_snbep_unc_r2pcie.3 libpfm_intel_snbep_unc_r3qpi.3 libpfm_intel_ivbep_unc_cbo.3 libpfm_intel_ivbep_unc_ha.3 libpfm_intel_ivbep_unc_imc.3 libpfm_intel_ivbep_unc_pcu.3 libpfm_intel_ivbep_unc_qpi.3 libpfm_intel_ivbep_unc_ubo.3 libpfm_intel_ivbep_unc_r2pcie.3 libpfm_intel_ivbep_unc_r3qpi.3 libpfm_intel_ivbep_unc_irp.3 libpfm_intel_knc.3 libpfm_intel_hswep_unc_cbo.3 libpfm_intel_hswep_unc_ha.3 libpfm_intel_hswep_unc_imc.3 libpfm_intel_hswep_unc_irp.3 libpfm_intel_hswep_unc_pcu.3 libpfm_intel_hswep_unc_qpi.3 libpfm_intel_hswep_unc_r2pcie.3 libpfm_intel_hswep_unc_r3qpi.3 libpfm_intel_hswep_unc_sbo.3 libpfm_intel_hswep_unc_ubo.3 libpfm_intel_bdx_unc_cbo.3 libpfm_intel_bdx_unc_ha.3 libpfm_intel_bdx_unc_imc.3 libpfm_intel_bdx_unc_irp.3 libpfm_intel_bdx_unc_pcu.3 libpfm_intel_bdx_unc_qpi.3 libpfm_intel_bdx_unc_r2pcie.3 libpfm_intel_bdx_unc_r3qpi.3 libpfm_intel_bdx_unc_sbo.3 libpfm_intel_bdx_unc_ubo.3 libpfm_intel_skx_unc_cha.3 libpfm_intel_skx_unc_imc.3 libpfm_intel_skx_unc_irp.3 libpfm_intel_skx_unc_m2m.3 libpfm_intel_skx_unc_m3upi.3 libpfm_intel_skx_unc_pcu.3 libpfm_intel_skx_unc_ubo.3 libpfm_intel_skx_unc_upi.3 pfm_get_perf_event_encoding.3 libpfm_perf_event_raw.3 /usr/local/share/man/man3 )
make[1]: Leaving directory '/home/username/libpfm4/docs'
I can now see the library in /usr/local/libpfm.{a,so,so.4,so.4.11.1}.
Compiling the program
#include <stdio.h>
#include <perfmon/pfmlib.h>
int main(int argc, char **argv){
int idx;
pfm_os_t os;
pfm_event_info_t info;
idx = 239075328;
os = PFM_OS_NONE;
pfm_initialize();
pfm_get_event_info(idx, os, &info);
printf("Name: %s\n"
"Desc: %s\n"
"Equiv: %s\n"
"Code: %lu\n"
"IDX: %d\n"
"Attr: %d\n",
info.name,
info.desc,
info.equiv,
info.code,
info.idx,
info.nattrs);
return 0;
}
I use this to compile:
gcc -lpfm -Wall -Werror -std=gnu11 -pthread -g -o0 -fno-omit-frame-pointer -I include -o out.bin code.c
I get a clean output.
Running the program
$ ./out.bin
./out.bin: error while loading shared libraries: libpfm.so.4: cannot open shared object file: No such file or directory
If I use ldd, I get this:
$ ldd out.bin
linux-vdso.so.1 (0x00007ffc8f9fe000)
libpfm.so.4 => not found
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fdcdcf0b000)
libc.so.6 => /lib64/libc.so.6 (0x00007fdcdcd40000)
/lib64/ld-linux-x86-64.so.2 (0x00007fdcdcf44000)
What may I be missing?
There's a difference between the link-time path to a library and the run-time path.
Since the library is in a location that (apparently) isn't handled by the run-time loader you must add a flag when linking to tell the linker to add information about it in the executable for the run-time loader to check.
This is done with the -rpath linker specific flag.
You can pass it using gcc with the -Wl option:
gcc ... -Wl,-rpath=/usr/local/lib -L/usr/local/lib -lpfm

build error using CMake

I get a build error when trying to build a flex and lemon project with CMake. Can you help me find what is wrong?
$ make
/usr/bin/cmake -H/home/dac/ClionProjects/openshell -B/home/dac/ClionProjects/openshell --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/dac/ClionProjects/openshell/CMakeFiles /home/dac/ClionProjects/openshell/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/dac/ClionProjects/openshell'
make -f CMakeFiles/lemon.dir/build.make CMakeFiles/lemon.dir/depend
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
cd /home/dac/ClionProjects/openshell && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell/CMakeFiles/lemon.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
make -f CMakeFiles/lemon.dir/build.make CMakeFiles/lemon.dir/build
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
make[2]: Nothing to be done for 'CMakeFiles/lemon.dir/build'.
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
/usr/bin/cmake -E cmake_progress_report /home/dac/ClionProjects/openshell/CMakeFiles 1
[ 16%] Built target lemon
make -f CMakeFiles/openshell.dir/build.make CMakeFiles/openshell.dir/depend
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
cd /home/dac/ClionProjects/openshell && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell /home/dac/ClionProjects/openshell/CMakeFiles/openshell.dir/DependInfo.cmake --color=
Scanning dependencies of target openshell
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
make -f CMakeFiles/openshell.dir/build.make CMakeFiles/openshell.dir/build
make[2]: Entering directory '/home/dac/ClionProjects/openshell'
/usr/bin/cmake -E cmake_progress_report /home/dac/ClionProjects/openshell/CMakeFiles 2
[ 33%] Building C object CMakeFiles/openshell.dir/main.c.o
/usr/bin/cc -Wall -Werror -O3 -std=c99 -I/usr/include/readline -o CMakeFiles/openshell.dir/main.c.o -c /home/dac/ClionProjects/openshell/main.c
Linking C executable openshell
/usr/bin/cmake -E cmake_link_script CMakeFiles/openshell.dir/link.txt --verbose=1
/usr/bin/cc -Wall -Werror -O3 -std=c99 CMakeFiles/openshell.dir/main.c.o CMakeFiles/openshell.dir/errors.c.o CMakeFiles/openshell.dir/util.c.o CMakeFiles/openshell.dir/stack.c.o CMakeFiles/openshell.dir/flex/shellparser.c.o -o openshell -rdynamic -lreadline
CMakeFiles/openshell.dir/main.c.o: In function `main':
main.c:(.text.startup+0xef): undefined reference to `yylex_init'
main.c:(.text.startup+0x100): undefined reference to `yyset_in'
main.c:(.text.startup+0x12e): undefined reference to `yylex'
main.c:(.text.startup+0x13a): undefined reference to `yyget_text'
main.c:(.text.startup+0x178): undefined reference to `yylex_destroy'
collect2: error: ld returned 1 exit status
CMakeFiles/openshell.dir/build.make:188: recipe for target 'openshell' failed
make[2]: *** [openshell] Error 1
make[2]: Leaving directory '/home/dac/ClionProjects/openshell'
CMakeFiles/Makefile2:98: recipe for target 'CMakeFiles/openshell.dir/all' failed
make[1]: *** [CMakeFiles/openshell.dir/all] Error 2
make[1]: Leaving directory '/home/dac/ClionProjects/openshell'
Makefile:78: recipe for target 'all' failed
make: *** [all] Error 2
My CMake build file is
cmake_minimum_required (VERSION 2.6)
project (openshell)
set(CMAKE_VERBOSE_MAKEFILE on)
include_directories(/usr/include/readline)
#### Lemon bootstrap ####
ADD_EXECUTABLE(lemon lemon.c)
file(GLOB SOURCES "./*.c")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -O3 -std=c99")
add_executable(openshell main.c openshell.h errors.c errors.h util.c util.h stack.c stack.h flex/shellparser.c flex/shellscanner.l flex/shellscanner.h)
target_link_libraries(openshell readline)
You're not linking the Flex library, so you will get linker errors for any Flex functions you use, such as yyset_in.
You can use find_package(FLEX) and after using FLEX_TARGET to define your Flex targets, you can then use something like the following:
# Note: I use "ShellScanner" below as in FLEX_TARGET(ShellScanner flex/shellscanner.l ...)
add_executable(openshell
...
flex/shellparser.c
${FLEX_ShellScanner_OUTPUTS}
)
target_link_libraries(openshell ${READLINE_LIBRARY} ${FLEX_LIBRARIES})
See FindFLEX for more information.
However, I don't see a FindReadline.cmake module with the other modules that CMake provides by default, so you might have to create one yourself or use an existing one such as the one I just linked. There's also the Editline library, which provides similar functionality, and you can use an existing FindEditline.cmake file for that too.

I can not include glib in header file, but I can include in source file with Raspberry Pi

Currently, I am working with Raspberry Pi:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 8.0 (jessie)
Release: 8.0
Codename: jessie
I have some libraries (C language) that look like bellow:
my_app\-my_app.c
\ - CMakeLists.txt
\-lib
\-lib1\- CMakeLists.txt
\- src
\- lib1.c
\- CMakeLists.txt
\- include
\- lib1.h
\- cmake
\- modules
\- FindGLIB2.cmake
\- MacroOutOfSourceBuild.cmake
....................
The lib1 is depends on glib
#include <glib.h>
Here's my CMakeLists.txt for my_app
cmake_minimum_required(VERSION 2.8)
project(my_app)
set(CMAKE_MODULE_PATH ${my_app_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
# Enable C11 or at least C99
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-std=c11" COMPILER_SUPPORTS_C11)
CHECK_C_COMPILER_FLAG("-std=c99" COMPILER_SUPPORTS_C99)
if(COMPILER_SUPPORTS_C11)
message(STATUS "Using C11.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
elseif(COMPILER_SUPPORTS_C99)
message(STATUS "The compiler ${CMAKE_C_COMPILER} has no C11 support. Using C99 instead.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
else()
message(STATUS "The compiler ${CMAKE_C_COMPILER} has no C11 nor C99 support. Please update your C compiler.")
endif()
SET (CMAKE_C_FLAGS "-lm")
include(MacroOutOfSourceBuild)
include(TargetDistclean)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build.")
add_subdirectory(lib/lib2)
add_subdirectory(lib/lib1)
include_directories(${lib2_SOURCE_DIR}/include)
include_directories(${lib1_SOURCE_DIR}/include)
# Add sources
set(my_app_SOURCES my_app.c)
add_executable(my_app ${my_app_SOURCES})
target_link_libraries(my_app
lib2
lib1
)
install(TARGETS my_app
RUNTIME DESTINATION bin
)
Here's my CMakeLists.txt for my_app/lib1
cmake_minimum_required(VERSION 2.8)
project(lib1)
set(CMAKE_MODULE_PATH ${lib1_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
SET (CMAKE_C_FLAGS "")
include(MacroOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build.")
add_subdirectory(src)
install(DIRECTORY include/lib1 DESTINATION include)
Here's my CMakeLists.txt for my_app/lib1/src
# Include the directory itself as a path to include directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(FindGLIB2)
include_directories(
${lib1_SOURCE_DIR}/include
${GLIB2_INCLUDE_DIRS}
)
set(lib1_SOURCES
lib1.c
)
add_library(lib1 ${lib1_SOURCES})
target_link_libraries(lib1
${GLIB2_LIBRARIES}
)
install(TARGETS lib1
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
Here is the log file:
pi#raspberrypi ~/my_app/build $ cmake ..
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.28")
-- checking for one of the modules 'glib-2.0'
-- Found GLib2: glib-2.0 /usr/include/glib-2.0;/usr/lib/arm-linux-gnueabihf/glib-2.0/include
-- Looking for include file glib/gregex.h
-- Looking for include file glib/gregex.h - not found
-- Looking for include file glib/gchecksum.h
-- Looking for include file glib/gchecksum.h - not found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/my_app/build
That means I already have glib on my system.
Now, I have this problems:
If I use #include <glib.h> only for lib1.c. Everything is OK.
If I use #include <glib.h> only for lib1.h. I saw this problem with lib1.h:
lib1.h:2:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
EDITED
The error come from my_app.c which include lib1.h
Here are more log with VERBOSE=yes
ERROR with lib1.h
pi#raspberrypi ~/my_app/build $ make VERBOSE=1
/usr/bin/cmake -H/home/pi/my_app -B/home/pi/my_app/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/pi/my_app/build/CMakeFiles /home/pi/my_app/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/pi/my_app/build'
make -f lib/bzle/src/CMakeFiles/bzle.dir/build.make lib/bzle/src/CMakeFiles/bzle.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/bzle/src /home/pi/my_app/build /home/pi/my_app/build/lib/bzle/src /home/pi/my_app/build/lib/bzle/src/CMakeFiles/bzle.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/bzle/src/CMakeFiles/bzle.dir/build.make lib/bzle/src/CMakeFiles/bzle.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/bzle/src/CMakeFiles/bzle.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 3 4 5 6 7 8 9 10 11 12 13 14
[ 60%] Built target bzle
make -f lib/lib1/src/CMakeFiles/lib1.dir/build.make lib/lib1/src/CMakeFiles/lib1.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/lib1/src /home/pi/my_app/build /home/pi/my_app/build/lib/lib1/src /home/pi/my_app/build/lib/lib1/src/CMakeFiles/lib1.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/lib1/src/CMakeFiles/lib1.dir/build.make lib/lib1/src/CMakeFiles/lib1.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/lib1/src/CMakeFiles/lib1.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 1 2
[ 70%] Built target lib1
make -f lib/lib2/src/CMakeFiles/lib2.dir/build.make lib/lib2/src/CMakeFiles/lib2.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/lib2/src /home/pi/my_app/build /home/pi/my_app/build/lib/lib2/src /home/pi/my_app/build/lib/lib2/src/CMakeFiles/lib2.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/lib2/src/CMakeFiles/lib2.dir/build.make lib/lib2/src/CMakeFiles/lib2.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/lib2/src/CMakeFiles/lib2.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 20
[ 75%] Built target lib2
make -f lib/ini/src/CMakeFiles/ini.dir/build.make lib/ini/src/CMakeFiles/ini.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/ini/src /home/pi/my_app/build /home/pi/my_app/build/lib/ini/src /home/pi/my_app/build/lib/ini/src/CMakeFiles/ini.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/ini/src/CMakeFiles/ini.dir/build.make lib/ini/src/CMakeFiles/ini.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/ini/src/CMakeFiles/ini.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 18
[ 80%] Built target ini
make -f CMakeFiles/my_app.dir/build.make CMakeFiles/my_app.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app /home/pi/my_app/build /home/pi/my_app/build /home/pi/my_app/build/CMakeFiles/my_app.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f CMakeFiles/my_app.dir/build.make CMakeFiles/my_app.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 19
[ 85%] Building C object CMakeFiles/my_app.dir/my_app.c.o
/usr/bin/cc -lm -I/home/pi/my_app/lib/bzle/include -I/home/pi/my_app/lib/ini/include -I/home/pi/my_app/lib/lib2/include -I/home/pi/my_app/lib/lib1/include -o CMakeFiles/my_app.dir/my_app.c.o -c /home/pi/my_app/my_app.c
In file included from /home/pi/my_app/my_app.c:53:0:
/home/pi/my_app/lib/lib1/include/lib1/lib1.h:2:18: fatal error: glib.h: No such file or directory
#include <glib.h>
^
compilation terminated.
CMakeFiles/my_app.dir/build.make:54: recipe for target 'CMakeFiles/my_app.dir/my_app.c.o' failed
make[2]: *** [CMakeFiles/my_app.dir/my_app.c.o] Error 1
make[2]: Leaving directory '/home/pi/my_app/build'
CMakeFiles/Makefile2:94: recipe for target 'CMakeFiles/my_app.dir/all' failed
make[1]: *** [CMakeFiles/my_app.dir/all] Error 2
make[1]: Leaving directory '/home/pi/my_app/build'
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2
OK with lib1.c
pi#raspberrypi ~/my_app/build $ make VERBOSE=1
/usr/bin/cmake -H/home/pi/my_app -B/home/pi/my_app/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/pi/my_app/build/CMakeFiles /home/pi/my_app/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/pi/my_app/build'
make -f lib/bzle/src/CMakeFiles/bzle.dir/build.make lib/bzle/src/CMakeFiles/bzle.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/bzle/src /home/pi/my_app/build /home/pi/my_app/build/lib/bzle/src /home/pi/my_app/build/lib/bzle/src/CMakeFiles/bzle.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/bzle/src/CMakeFiles/bzle.dir/build.make lib/bzle/src/CMakeFiles/bzle.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/bzle/src/CMakeFiles/bzle.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 3 4 5 6 7 8 9 10 11 12 13 14
[ 60%] Built target bzle
make -f lib/lib1/src/CMakeFiles/lib1.dir/build.make lib/lib1/src/CMakeFiles/lib1.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/lib1/src /home/pi/my_app/build /home/pi/my_app/build/lib/lib1/src /home/pi/my_app/build/lib/lib1/src/CMakeFiles/lib1.dir/DependInfo.cmake --color=
Dependee "../lib/lib1/include/lib1/other_beacon.h" is newer than depender "lib/lib1/src/CMakeFiles/lib1.dir/other_beacon.c.o".
Dependee "/home/pi/my_app/lib/lib1/src/other_beacon.c" is newer than depends file "/home/pi/my_app/build/lib/lib1/src/CMakeFiles/lib1.dir/depend.internal".
Clearing dependencies in "/home/pi/my_app/build/lib/lib1/src/CMakeFiles/lib1.dir/depend.make".
Scanning dependencies of target lib1
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/lib1/src/CMakeFiles/lib1.dir/build.make lib/lib1/src/CMakeFiles/lib1.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 1
[ 65%] Building C object lib/lib1/src/CMakeFiles/lib1.dir/other_beacon.c.o
cd /home/pi/my_app/build/lib/lib1/src && /usr/bin/cc -I/home/pi/my_app/build/lib/lib1/src -I/home/pi/my_app/lib/lib1/src -I/home/pi/my_app/lib/lib1/include -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/home/pi/my_app/lib/bzle/include -o CMakeFiles/lib1.dir/other_beacon.c.o -c /home/pi/my_app/lib/lib1/src/other_beacon.c
Linking C static library liblib1.a
cd /home/pi/my_app/build/lib/lib1/src && /usr/bin/cmake -P CMakeFiles/lib1.dir/cmake_clean_target.cmake
cd /home/pi/my_app/build/lib/lib1/src && /usr/bin/cmake -E cmake_link_script CMakeFiles/lib1.dir/link.txt --verbose=1
/usr/bin/ar cr liblib1.a CMakeFiles/lib1.dir/other_beacon.c.o CMakeFiles/lib1.dir/ibeacon.c.o
/usr/bin/ranlib liblib1.a
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 1 2
[ 70%] Built target lib1
make -f lib/lib2/src/CMakeFiles/lib2.dir/build.make lib/lib2/src/CMakeFiles/lib2.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/lib2/src /home/pi/my_app/build /home/pi/my_app/build/lib/lib2/src /home/pi/my_app/build/lib/lib2/src/CMakeFiles/lib2.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/lib2/src/CMakeFiles/lib2.dir/build.make lib/lib2/src/CMakeFiles/lib2.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/lib2/src/CMakeFiles/lib2.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 20
[ 75%] Built target lib2
make -f lib/ini/src/CMakeFiles/ini.dir/build.make lib/ini/src/CMakeFiles/ini.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/ini/src /home/pi/my_app/build /home/pi/my_app/build/lib/ini/src /home/pi/my_app/build/lib/ini/src/CMakeFiles/ini.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/ini/src/CMakeFiles/ini.dir/build.make lib/ini/src/CMakeFiles/ini.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
make[2]: Nothing to be done for 'lib/ini/src/CMakeFiles/ini.dir/build'.
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 18
[ 80%] Built target ini
make -f CMakeFiles/my_app.dir/build.make CMakeFiles/my_app.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app /home/pi/my_app/build /home/pi/my_app/build /home/pi/my_app/build/CMakeFiles/my_app.dir/DependInfo.cmake --color=
Dependee "../lib/lib1/include/lib1/other_beacon.h" is newer than depends file "/home/pi/my_app/build/CMakeFiles/my_app.dir/depend.internal".
Clearing dependencies in "/home/pi/my_app/build/CMakeFiles/my_app.dir/depend.make".
Scanning dependencies of target my_app
make[2]: Leaving directory '/home/pi/my_app/build'
make -f CMakeFiles/my_app.dir/build.make CMakeFiles/my_app.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 19
[ 85%] Building C object CMakeFiles/my_app.dir/my_app.c.o
/usr/bin/cc -lm -I/home/pi/my_app/lib/bzle/include -I/home/pi/my_app/lib/ini/include -I/home/pi/my_app/lib/lib2/include -I/home/pi/my_app/lib/lib1/include -o CMakeFiles/my_app.dir/my_app.c.o -c /home/pi/my_app/my_app.c
Linking C executable my_app
/usr/bin/cmake -E cmake_link_script CMakeFiles/my_app.dir/link.txt --verbose=1
/usr/bin/cc -lm CMakeFiles/my_app.dir/my_app.c.o -o my_app -rdynamic lib/bzle/src/libbzle.a lib/ini/src/libini.a lib/lib2/src/liblib2.a lib/lib1/src/liblib1.a lib/bzle/src/libbzle.a -lglib-2.0
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 19
[ 85%] Built target my_app
make -f lib/bzle/tools/CMakeFiles/hciconfig.dir/build.make lib/bzle/tools/CMakeFiles/hciconfig.dir/depend
make[2]: Entering directory '/home/pi/my_app/build'
cd /home/pi/my_app/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pi/my_app /home/pi/my_app/lib/bzle/tools /home/pi/my_app/build /home/pi/my_app/build/lib/bzle/tools /home/pi/my_app/build/lib/bzle/tools/CMakeFiles/hciconfig.dir/DependInfo.cmake --color=
Dependee "/home/pi/my_app/build/lib/bzle/tools/CMakeFiles/hciconfig.dir/DependInfo.cmake" is newer than depender "/home/pi/my_app/build/lib/bzle/tools/CMakeFiles/hciconfig.dir/depend.internal".
Dependee "/home/pi/my_app/build/lib/bzle/tools/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/pi/my_app/build/lib/bzle/tools/CMakeFiles/hciconfig.dir/depend.internal".
Scanning dependencies of target hciconfig
make[2]: Leaving directory '/home/pi/my_app/build'
make -f lib/bzle/tools/CMakeFiles/hciconfig.dir/build.make lib/bzle/tools/CMakeFiles/hciconfig.dir/build
make[2]: Entering directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 15
[ 90%] Building C object lib/bzle/tools/CMakeFiles/hciconfig.dir/csr.c.o
cd /home/pi/my_app/build/lib/bzle/tools && /usr/bin/cc -Wall -I/home/pi/my_app/build/lib/bzle/tools -I/home/pi/my_app/lib/bzle/tools -I/home/pi/my_app/lib/bzle/include -o CMakeFiles/hciconfig.dir/csr.c.o -c /home/pi/my_app/lib/bzle/tools/csr.c
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 16
[ 95%] Building C object lib/bzle/tools/CMakeFiles/hciconfig.dir/hciconfig.c.o
cd /home/pi/my_app/build/lib/bzle/tools && /usr/bin/cc -Wall -I/home/pi/my_app/build/lib/bzle/tools -I/home/pi/my_app/lib/bzle/tools -I/home/pi/my_app/lib/bzle/include -o CMakeFiles/hciconfig.dir/hciconfig.c.o -c /home/pi/my_app/lib/bzle/tools/hciconfig.c
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 17
[100%] Building C object lib/bzle/tools/CMakeFiles/hciconfig.dir/textfile.c.o
cd /home/pi/my_app/build/lib/bzle/tools && /usr/bin/cc -Wall -I/home/pi/my_app/build/lib/bzle/tools -I/home/pi/my_app/lib/bzle/tools -I/home/pi/my_app/lib/bzle/include -o CMakeFiles/hciconfig.dir/textfile.c.o -c /home/pi/my_app/lib/bzle/tools/textfile.c
Linking C executable hciconfig
cd /home/pi/my_app/build/lib/bzle/tools && /usr/bin/cmake -E cmake_link_script CMakeFiles/hciconfig.dir/link.txt --verbose=1
/usr/bin/cc -Wall CMakeFiles/hciconfig.dir/csr.c.o CMakeFiles/hciconfig.dir/hciconfig.c.o CMakeFiles/hciconfig.dir/textfile.c.o -o hciconfig -rdynamic ../src/libbzle.a -lglib-2.0
make[2]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_report /home/pi/my_app/build/CMakeFiles 15 16 17
[100%] Built target hciconfig
make[1]: Leaving directory '/home/pi/my_app/build'
/usr/bin/cmake -E cmake_progress_start /home/pi/my_app/build/CMakeFiles 0
I have know ideas about this.
Could you please give me some advice?

CMake: cannot compile out of source project with subprojects

I have a project (with 3 subprojects) with CMake that builds perfectly when I execute cmake in the same directory as the top CMakeLists.txt. But when I try an out of source build I get the following error:
javsalgar#javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi$ mkdir build
javsalgar#javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi$ cd build/
javsalgar#javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi/build$ ls
javsalgar#javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi/build$ cmake ..
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- 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
-- 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
-- Configuring done
-- Generating done
-- Build files have been written to: /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build
javsalgar#javsalgar-laptop:~/LocalWork/eclipse_workspace/mpiperf_pi/build$ make
/usr/bin/cmake -H/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi -B/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make -f pi_mpireduce/CMakeFiles/pi_mpireduce.dir/build.make pi_mpireduce/CMakeFiles/pi_mpireduce.dir/depend
make[2]: Entering directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce/CMakeFiles/pi_mpireduce.dir/DependInfo.cmake --color=
Scanning dependencies of target pi_mpireduce
make[2]: Leaving directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make -f pi_mpireduce/CMakeFiles/pi_mpireduce.dir/build.make pi_mpireduce/CMakeFiles/pi_mpireduce.dir/build
make[2]: Entering directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
/usr/bin/cmake -E cmake_progress_report /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles 1
[ 20%] Building C object pi_mpireduce/CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce && mpicc -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/include -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/include -o CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o -c /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/src/mpi_pi_reduce.c
/usr/bin/cmake -E cmake_progress_report /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/CMakeFiles 2
[ 40%] Building C object pi_mpireduce/CMakeFiles/pi_mpireduce.dir/src/dboard.c.o
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce && mpicc -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/include -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce -I/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/include -o CMakeFiles/pi_mpireduce.dir/src/dboard.c.o -c /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/pi_mpireduce/src/dboard.c
Linking C executable .
cd /home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build/pi_mpireduce && /usr/bin/cmake -E cmake_link_script CMakeFiles/pi_mpireduce.dir/link.txt --verbose=1
mpicc CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o CMakeFiles/pi_mpireduce.dir/src/dboard.c.o -o . -rdynamic -lmpi
/usr/bin/ld: cannot open output file .: Is a directory
collect2: error: ld returned 1 exit status
make[2]: *** [pi_mpireduce] Error 1
make[2]: Leaving directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make[1]: *** [pi_mpireduce/CMakeFiles/pi_mpireduce.dir/all] Error 2
make[1]: Leaving directory `/home/javsalgar/LocalWork/eclipse_workspace/mpiperf_pi/build'
make: *** [all] Error 2
I found out what the problem was. The executable and the directory of the subproject had the same name. Chaning the executable name did the trick.
The line
mpicc CMakeFiles/pi_mpireduce.dir/src/mpi_pi_reduce.c.o CMakeFiles/pi_mpireduce.dir/src/dboard.c.o -o . -rdynamic -lmpi
tells the linker that the output name of the compilation shall be ., which is not a valid name for an executable or library or anything at all. This may come from you setting a target name from a variable that is empty during configure time or you accidentally wrote a . there.

Resources