diff --git a/.gitignore b/.gitignore index 6caa0a6..c923f6e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ *.obj *.lib *.exe -*~ \ No newline at end of file +*~ +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b5949f2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.0) + +# Define project +project(sexpresso VERSION 1.0.0 DESCRIPTION "A C++ centric s-expression parser library.") + +# Shared library specification +add_library(sexpresso SHARED sexpresso/sexpresso.cpp) + +# Set up version +set_target_properties(sexpresso PROPERTIES VERSION ${PROJECT_VERSION}) +set_target_properties(sexpresso PROPERTIES SOVERSION 1) + +# Set up headers (public API) +set_target_properties(sexpresso PROPERTIES PUBLIC_HEADER sexpresso/sexpresso.hpp) + +# Install rule +include(GNUInstallDirs) +install( + TARGETS sexpresso + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) + +# Generate pkg-config file +configure_file(sexpresso.pc.in sexpresso.pc @ONLY) +install( + FILES ${CMAKE_BINARY_DIR}/sexpresso.pc + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig +) diff --git a/README.org b/README.org index deec3b0..d7bed01 100644 --- a/README.org +++ b/README.org @@ -33,6 +33,16 @@ more unclearness of what includes what (since it ends up being a big chain), you After that you can move onward! +** Building with CMake + +The project can be installed as a shared library using CMake: + +#+BEGIN_SRC sh +mkdir build && cd build +cmake .. +make && make install +#+END_SRC + ** Parsing #+BEGIN_SRC c++ diff --git a/sexpresso.pc.in b/sexpresso.pc.in new file mode 100644 index 0000000..aa3cdd9 --- /dev/null +++ b/sexpresso.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ + +Requires: +Libs: -L${libdir} -lsexpresso +Cflags: -I${includedir}