Change build system to CMake
This commit is contained in:
26
CMakeLists.txt
Normal file
26
CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
|
||||||
|
project(cyberiadaml VERSION 1.0)
|
||||||
|
|
||||||
|
find_package(LibXml2 REQUIRED)
|
||||||
|
if(!LibXml2_FOUND)
|
||||||
|
message(FATAL_ERROR "Cannot find libxml2 library")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(cyberiadaml SHARED cyberiadaml.c utf8enc.c cyb_types.c cyb_string.c)
|
||||||
|
target_include_directories(cyberiadaml PUBLIC
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
"${LIBXML2_INCLUDE_DIR}")
|
||||||
|
target_link_directories(cyberiadaml PUBLIC "${LIBXML2_LIBRARY}")
|
||||||
|
target_link_libraries(cyberiadaml PUBLIC
|
||||||
|
"${LIBXML2_LIBRARIES}"
|
||||||
|
m)
|
||||||
|
|
||||||
|
add_executable(cyberiada_test test.c)
|
||||||
|
target_include_directories(cyberiada_test PUBLIC "${PROJECT_BINARY_DIR}")
|
||||||
|
target_link_directories(cyberiada_test PUBLIC "${PROJECT_BINARY_DIR}")
|
||||||
|
target_link_libraries(cyberiada_test PUBLIC cyberiadaml)
|
||||||
|
|
||||||
|
install(TARGETS cyberiadaml DESTINATION lib)
|
||||||
|
install(FILES cyberiadaml.h ${CMAKE_CURRENT_SOURCE_DIR}/cyberiadaml.h
|
||||||
|
DESTINATION include/cyberiadaml)
|
||||||
11
README.md
11
README.md
@@ -10,13 +10,14 @@ the GNU Free Documentation License (version 1.3).
|
|||||||
|
|
||||||
* build-essential
|
* build-essential
|
||||||
* libxml2-dev
|
* libxml2-dev
|
||||||
|
* cmake (version 3.12+)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Run `make` to build the library binaries.
|
Create `build` directory: `mkdir build && cd build`
|
||||||
|
|
||||||
Run `make test` to build the test program.
|
Run `cmake ..` to build the library binaries and the test program.
|
||||||
|
|
||||||
Use variables:
|
Run `make install` to install the library.
|
||||||
* `DEBUG=yes` debug version of the library
|
|
||||||
* `DYNAMIC=1` build shared version of the library
|
Use CMake parameters to change the build type / installation prefix / etc.
|
||||||
|
|||||||
Reference in New Issue
Block a user