Here is my actual code:
I'm trying to create a cmake build system for gpslib.
cmake_minimum_required(VERSION 2.6)
set(PROJECT_NAME LOGGER)
project(${PROJECT_NAME})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "res/cmake/Modules/")
add_library(gps_lib STATIC "")
target_link_libraries(gps_lib m)
target_include_directories(gps_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src ${LIBM_INCLUDE_DIRS})
target_sources(gps_lib PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/gps.h
${CMAKE_CURRENT_SOURCE_DIR}/src/nmea.h
${CMAKE_CURRENT_SOURCE_DIR}/src/serial.h)
target_sources(gps_lib PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/gps.c
${CMAKE_CURRENT_SOURCE_DIR}/src/nmea.c
${CMAKE_CURRENT_SOURCE_DIR}/src/serial.c)
target_link_libraries(gps_lib PUBLIC ${LIBM_LIBRARIES})
add_executable(${PROJECT_NAME} examples/position_logger.c)
target_link_libraries(${PROJECT_NAME}gps_lib)
Does anybody know how to build this project?
This is the error message:
/usr/bin/ld: libgps_lib.a(gps.c.o): in function `gps_deg_dec': gps.c:(.text+0x2d5): undefined reference to `round'
/usr/bin/ld: gps.c:(.text+0x312): undefined reference to `round'
In the res/cmake/Modules is a FindLibM.cmake Module from FindLibM.cmake
Edit due to compor answear:
- added link libraries for gps_lib
- removed LIBM_LIBRARIES from PROJECT_NAME link library
Does not change anything
Thanks to @KamilCuk I solved the Problem.
link_libraries(m) or target_link_libraries(gps_lib m) (only for the target gps_lib)
must be added to the cmake File
Thanks to everbody who helped me to find my errors!