blob: 134d7cf31715536fb253f8a5af44c77068ed3e36 [file] [log] [blame]
Lawrence Tang1b0b00e2022-07-05 10:33:10 +01001cmake_minimum_required(VERSION 3.10)
2include(FetchContent)
3project(CPERParse)
4
5# Output into subdirectories /lib and /bin.
6set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
7set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
8set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
9set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
10
11# Fetch json-c from git repository.
12FetchContent_Declare(
13 json-c
14 GIT_REPOSITORY https://github.com/json-c/json-c.git
15 GIT_TAG d28ac67dde77566f53a97f22b4ea7cb36afe6582 # 4/6/2022
16)
17FetchContent_MakeAvailable(json-c)
18
19# Add library and test executable.
20file(GLOB SectionSources sections/*.c)
21file(GLOB EDKSources edk/*.c)
22add_library(CPERParseLibrary STATIC cper-parse.c cper-utils.c ${SectionSources} ${EDKSources})
23add_executable(CPERParseTest cper-test.c)
24
25# Link library.
26target_link_libraries(CPERParseLibrary json-c)
27target_link_libraries(CPERParseTest CPERParseLibrary)