1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
if(ENABLE_OBJC AND ENABLE_DARWIN_OSL)
set(CMAKE_OBJC_FLAGS "${CMAKE_OBJC_FLAGS} -fobjc-arc")
# Take care, this must follow any compiler setting overrides! (e.g. set(CMAKE_OBJC_COMPILER clang) etc.)
enable_language(OBJC)
set(DARWINOSL_SOURCES
darwinosl-plugin.c
darwinosl-source.m
darwinosl-source.h
darwinosl-source-oslog.m
darwinosl-source-oslog.h
darwinosl-source-persist.c
darwinosl-source-persist.h
darwinosl-parser.c
darwinosl-parser.h
darwinosl-grammar.y
${CMAKE_CURRENT_BINARY_DIR}/darwinosl-grammar.c
${CMAKE_CURRENT_BINARY_DIR}/darwinosl-grammar.h
)
if(ENABLE_DARWIN_OSL)
include(CheckOBJCSourceCompiles)
# TODO: Once gcc was able to compile our ObjC code correctly we should add here a more sopgisticated check
check_objc_source_compiles("
#include <OSLog/OSLog.h>
int main(int, char**)
{ return 0; }
" HAVE_OSLOG)
if(HAVE_OSLOG)
generate_y_from_ym(modules/darwinosl/darwinosl-grammar)
bison_target(DarwinOSLGrammar
${CMAKE_CURRENT_BINARY_DIR}/darwinosl-grammar.y
${CMAKE_CURRENT_BINARY_DIR}/darwinosl-grammar.c
COMPILE_FLAGS ${BISON_FLAGS})
add_module(
TARGET darwinosl
GRAMMAR darwinosl-grammar
SOURCES ${DARWINOSL_SOURCES}
)
target_link_libraries(darwinosl PRIVATE
"-framework Foundation"
"-framework OSLog"
)
target_link_options(darwinosl PRIVATE -ObjC)
else()
message(STATUS "OSLog is not supported on this system")
endif()
endif()
endif()
|