Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
src/c/CMakeLists.txt: set pthreads c flag, use cmake var for c99 std
Browse files Browse the repository at this point in the history
Previously, this would fail in a clean ubuntu 18.04 instance with:

[100%] Linking C executable device-grove
/usr/bin/ld: CMakeFiles/device-grove.dir/main.c.o: undefined reference to symbol 'sem_post@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

This is the simplest way to link to pthreads from this project without
digging into the c-sdk, etc.

Also set the c standard to c99 in a more portable way by setting 
CMAKE_C_STANDARD.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
  • Loading branch information
anonymouse64 committed Jun 27, 2019
1 parent 2b9c26e commit ba8a39d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ endif ()
if (DEFINED CMAKE_C_COMPILER_ID)
if (CMAKE_C_COMPILER_ID MATCHES GNU)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wstrict-prototypes -Wmissing-prototypes")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set (CMAKE_C_STANDARD 99)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -O0")
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -ggdb -O0")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG")
Expand Down

0 comments on commit ba8a39d

Please sign in to comment.