Skip to content

Commit

Permalink
provide cjson via cmake subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryptkeeper committed May 3, 2024
1 parent 96d3eb9 commit e5b385a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
7 changes: 5 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "logc"]
path = logc
[submodule "dep/cJSON"]
path = dep/cJSON
url = https://github.com/DaveGamble/cJSON.git
[submodule "dep/logc"]
path = dep/logc
url = https://github.com/rxi/log.c.git
14 changes: 6 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@ cmake_minimum_required(VERSION 3.22)

project(fsautoproc C)

add_library(logc STATIC "logc/src/log.c" "logc/src/log.h")
add_library(logc STATIC "dep/logc/src/log.c" "dep/logc/src/log.h")
target_compile_definitions(logc PRIVATE LOG_USE_COLOR)

add_subdirectory(dep/cJSON)

# use strict C11
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -pedantic")

# find cJSON using pkg-config
find_package(PkgConfig REQUIRED)
pkg_check_modules(CJSON REQUIRED libcjson)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic")

file(GLOB SOURCES "src/*.c")
file(GLOB HEADERS "include/*.h")
add_executable(fsautoproc ${SOURCES} ${HEADERS})

target_link_directories(fsautoproc PRIVATE ${CJSON_LIBRARY_DIRS})
target_link_libraries(fsautoproc PRIVATE logc ${CJSON_LIBRARIES} pthread)
target_link_libraries(fsautoproc PRIVATE dep/logc ${CJSON_LIBRARIES} pthread)

target_include_directories(fsautoproc PRIVATE "include" "logc/src" ${CJSON_INCLUDE_DIRS})
target_include_directories(fsautoproc PRIVATE "include" "dep/logc/src" ${CJSON_INCLUDE_DIRS})

install(TARGETS fsautoproc DESTINATION bin)
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Before using, consider:

## Building

`fsautoproc` is built with CMake. You will need a C99 compiler and CMake installed. The utility is primarily written for use on Linux and BSD systems (including macOS). It may work on Windows with WSL or Cygwin, but this is currently untested.
`fsautoproc` is built with CMake. You will need a C11 compiler and CMake installed. The utility is primarily written for use on Linux and BSD systems (including macOS). It may work on Windows with WSL or Cygwin, but this is currently untested.

1. Clone the repository and its submodules: `git clone --recursive https://github.com/Cryptkeeper/fsautoproc`
2. Build the CMake project with `cmake -B build`
Expand All @@ -30,13 +30,10 @@ Before using, consider:

### Dependencies

Your build environment must provide:

- [cJSON](https://github.com/DaveGamble/cJSON)

Git submodules provide:

- [log.c](https://github.com/rxi/log.c)
- [cJSON](https://github.com/DaveGamble/cJSON)

### Usage

Expand Down
1 change: 1 addition & 0 deletions dep/cJSON
Submodule cJSON added at 19396a
Submodule logc updated from 000000 to f9ea34

0 comments on commit e5b385a

Please sign in to comment.