blob: 041d88cba879a1e01bbcfeaeaef7054cf536273d [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)
Lawrence Tangd7e8ca32022-07-07 10:25:53 +010017
18# Fetch b64-c from git repository.
19FetchContent_Declare(
20 b64-c
21 GIT_REPOSITORY https://github.com/jwerle/b64.c.git
22 GIT_TAG c33188cd541f19b072ee4988d8224ea6c964bed1 # 9/2/2021
23)
24FetchContent_MakeAvailable(json-c b64-c)
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010025
26# Add library and test executable.
27file(GLOB SectionSources sections/*.c)
28file(GLOB EDKSources edk/*.c)
Lawrence Tang8a2d7372022-07-12 16:44:49 +010029add_library(CPERParseLibrary STATIC cper-parse.c ir-parse.c cper-utils.c json-schema.c json-schema.h ${SectionSources} ${EDKSources})
Lawrence Tang368e0b42022-07-07 14:31:06 +010030add_executable(CPERParseTest testing/cper-test.c)
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010031
32# Link library.
Lawrence Tangd7e8ca32022-07-07 10:25:53 +010033target_link_libraries(CPERParseLibrary json-c b64c)
Lawrence Tang1b0b00e2022-07-05 10:33:10 +010034target_link_libraries(CPERParseTest CPERParseLibrary)