Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake build script #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
*.obj
*.lib
*.exe
*~
*~
build/
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
10 changes: 10 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down
12 changes: 12 additions & 0 deletions sexpresso.pc.in
Original file line number Diff line number Diff line change
@@ -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}