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

Generated CMake C libraries do not correctly specify dependent generated source code filenames #285

Open
Gregory-Meyer opened this issue Sep 24, 2019 · 0 comments

Comments

@Gregory-Meyer
Copy link
Contributor

Given the following CMakeLists.txt:

cmake_minimum_required(VERSION 3.8)

project(lcm-toy)

find_package(lcm REQUIRED)
include(${LCM_USE_FILE})

lcm_wrap_types(C_SOURCES c_sources C_HEADERS c_headers vector_t.lcm)

lcm_add_library(lcm-toy C STATIC ${c_sources} ${c_headers})
target_include_directories(lcm-toy PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
)

and the LCM message definition file vector_t.lcm:

struct vector_t
{
    double x;
    double y;
    double z;
}

I get this failure when attempting to build the CMake project:

$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.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
-- Configuring done
-- Generating done-- Build files have been written to: /home/gregjm/c/lcm-toy/build
$ cmake --build .
Scanning dependencies of target lcm-toy.sources
[ 25%] Generating _vector_t.h, _vector_t.c
[ 25%] Built target lcm-toy.sources
[ 50%] Generating _vector_t.h, _vector_t.c
Scanning dependencies of target lcm-toy
[ 50%] Generating _vector_t.h, _vector_t.c
[ 75%] Building C object CMakeFiles/lcm-toy.dir/_vector_t.c.o
cc: error: /home/gregjm/c/lcm-toy/build/_vector_t.c: No such file or directory
cc: fatal error: no input files
compilation terminated.
gmake[2]: *** [CMakeFiles/lcm-toy.dir/build.make:70: CMakeFiles/lcm-toy.dir/_vector_t.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:104: CMakeFiles/lcm-toy.dir/all] Error 2
gmake: *** [Makefile:84: all] Error 2
$ ls
CMakeCache.txt  CMakeFiles/  cmake_install.cmake  Makefile  vector_t.c  vector_t.h

Note that the files vector_t.h and vector_t.c are being generated, but the target lcm-types is attempting to compile using the file _vector_t.c.

I have created a pull request, #284, to address this 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

1 participant