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
(...)
We forced the C standard to C99
We exposed the include directories from the library, so projects that link to mimick can use the include directories automagically.
This fixes the following errors:
fatal error: mimick.h: No such file or directory
In file included from mimick/src/core.c:32:
mimick/src/vitals.h:47:13: error: expected ‘;’ before ‘void’
47 | mmk_noreturn void mmk_panic(const char *, ...);
| ^~~~~
| ;
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
:This would cause multiple weird errors when building the library. To fix this we changed the mimick
CMakeLists.txt
:This fixes the following errors:
fatal error: mimick.h: No such file or directory
It looks like the include directories issue has been addressed in PR https://github.com/Snaipe/Mimick/pull/11