Snaipe / Mimick

A KISS, cross-platform C mocking library
MIT License
152 stars 43 forks source link

Including in a cmake project with C standard 11 directive makes this project not compile #28

Open grasmanek94 opened 3 years ago

grasmanek94 commented 3 years ago

We encountered an issue where we could build the library separately, but including it into our project made it fail to compile.

The way we include the library (simplified form multiple cmake files into one working example):

CMakeLists.txt:

cmake_minimum_required(VERSION 3.13)

project(proj LANGUAGES C VERSION 0.1)

set(CMAKE_C_STANDARD 11)

add_subdirectory(libraries/mimick/)

set(TEST_SOURCES
  main.c
  test.c
)

add_executable( Test ${TEST_SOURCES} )

target_include_directories( Test PRIVATE . )
target_link_libraries( Test mimick )

This would cause multiple weird errors when building the library. To fix this we changed the mimick CMakeLists.txt:

(...)
project (Mimick C)

set(CMAKE_C_STANDARD 99) # this has been added

(...)

add_library (mimick STATIC ${SOURCE_FILES})
target_include_directories(mimick PUBLIC include) # this has been added

(...)

This fixes the following errors:

It looks like the include directories issue has been addressed in PR https://github.com/Snaipe/Mimick/pull/11