Lawrence Tang | 1b0b00e | 2022-07-05 10:33:10 +0100 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.10) |
| 2 | include(FetchContent) |
| 3 | project(CPERParse) |
| 4 | |
| 5 | # Output into subdirectories /lib and /bin. |
| 6 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) |
| 7 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 8 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 9 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| 10 | |
| 11 | # Fetch json-c from git repository. |
| 12 | FetchContent_Declare( |
| 13 | json-c |
| 14 | GIT_REPOSITORY https://github.com/json-c/json-c.git |
| 15 | GIT_TAG d28ac67dde77566f53a97f22b4ea7cb36afe6582 # 4/6/2022 |
| 16 | ) |
Lawrence Tang | d7e8ca3 | 2022-07-07 10:25:53 +0100 | [diff] [blame] | 17 | |
| 18 | # Fetch b64-c from git repository. |
| 19 | FetchContent_Declare( |
| 20 | b64-c |
| 21 | GIT_REPOSITORY https://github.com/jwerle/b64.c.git |
| 22 | GIT_TAG c33188cd541f19b072ee4988d8224ea6c964bed1 # 9/2/2021 |
| 23 | ) |
| 24 | FetchContent_MakeAvailable(json-c b64-c) |
Lawrence Tang | 1b0b00e | 2022-07-05 10:33:10 +0100 | [diff] [blame] | 25 | |
| 26 | # Add library and test executable. |
| 27 | file(GLOB SectionSources sections/*.c) |
| 28 | file(GLOB EDKSources edk/*.c) |
Lawrence Tang | 02c801a | 2022-07-18 14:43:52 +0100 | [diff] [blame^] | 29 | file(GLOB GeneratorSectionSources generator/sections/*.c) |
Lawrence Tang | b8fa2f7 | 2022-07-18 10:50:19 +0100 | [diff] [blame] | 30 | add_library(cper-parse STATIC cper-parse.c ir-parse.c cper-utils.c json-schema.c json-schema.h ${SectionSources} ${EDKSources}) |
Lawrence Tang | 02c801a | 2022-07-18 14:43:52 +0100 | [diff] [blame^] | 31 | add_executable(cper-convert cli-app/cper-convert.c) |
| 32 | add_executable(cper-generate generator/cper-generate.c generator/gen-utils.c ${GeneratorSectionSources} ${EDKSources}) |
Lawrence Tang | 1b0b00e | 2022-07-05 10:33:10 +0100 | [diff] [blame] | 33 | |
| 34 | # Link library. |
Lawrence Tang | b8fa2f7 | 2022-07-18 10:50:19 +0100 | [diff] [blame] | 35 | target_link_libraries(cper-parse json-c b64c) |
| 36 | target_link_libraries(cper-convert cper-parse) |
| 37 | target_compile_options(cper-parse PRIVATE -Wno-address-of-packed-member) |
| 38 | |
| 39 | # Copy required specification JSON for command line application. |
| 40 | add_custom_command(TARGET cper-convert POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory bin/specification) |
| 41 | add_custom_command(TARGET cper-convert POST_BUILD COMMAND cp -r specification/json/* bin/specification) |