diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e364c52 --- /dev/null +++ b/CMakeLists.txt @@ -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) diff --git a/Makefile b/Makefile.old similarity index 100% rename from Makefile rename to Makefile.old diff --git a/README.md b/README.md index 4ae2fc8..0466df0 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,14 @@ the GNU Free Documentation License (version 1.3). * build-essential * libxml2-dev +* cmake (version 3.12+) ## 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: -* `DEBUG=yes` debug version of the library -* `DYNAMIC=1` build shared version of the library +Run `make install` to install the library. + +Use CMake parameters to change the build type / installation prefix / etc.