Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
cmake_minimum_required(VERSION 3.10)
project(libcyaml VERSION 2.0.0 LANGUAGES C)

# Version defines
add_compile_definitions(
VERSION_MAJOR=2
VERSION_MINOR=0
VERSION_PATCH=0
VERSION_DEVEL=1
)

# Set default build type to Debug if not specified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()

# Set output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Source files
set(LIBCYAML_SRC
src/mem.c
src/free.c
src/load.c
src/save.c
src/copy.c
src/util.c
src/utf8.c
)

# Include directories
include_directories(include)

# Find libyaml
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBYAML REQUIRED yaml-0.1)
include_directories(${LIBYAML_INCLUDE_DIRS})
link_directories(${LIBYAML_LIBRARY_DIRS})

# Build shared library
add_library(cyaml_shared SHARED ${LIBCYAML_SRC})
set_target_properties(cyaml_shared PROPERTIES OUTPUT_NAME cyaml)
target_link_libraries(cyaml_shared ${LIBYAML_LIBRARIES})

# Build static library
add_library(cyaml_static STATIC ${LIBCYAML_SRC})
set_target_properties(cyaml_static PROPERTIES OUTPUT_NAME cyaml)
target_link_libraries(cyaml_static ${LIBYAML_LIBRARIES})

# Examples
add_executable(planner examples/planner/main.c)
target_link_libraries(planner cyaml_static ${LIBYAML_LIBRARIES})

add_executable(numerical examples/numerical/main.c)
target_link_libraries(numerical cyaml_static ${LIBYAML_LIBRARIES})
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ with valgrind) can be built with:

make VARIANT=san


To build on Windows use CMake in conjunction with vcpkg

mkdir build; cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=\path\to\toolchain\file\vcpkg.cmake
cmake --build .

Note:
This does not currently build any tests etc, only static and dynamic libs.

Installation
------------

Expand Down