Skip to content

Commit

Permalink
Added basic CMake support (#66)
Browse files Browse the repository at this point in the history
This will enable package managers and projects that relies on CMake,
like [CPM](https://github.com/cpm-cmake/CPM.cmake) to add SimpleIni
as a dependency easily. Note that it does not enable building the test
harness using CMake, this is still via the Makefile.

Signed-off-by: Vinícius Ferrão <[email protected]>
  • Loading branch information
viniciusferrao authored Jul 14, 2023
1 parent 7350fcc commit db0e0b2
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.14)

project(
SimpleIni
VERSION 4.20
DESCRIPTION "Cross-platform C++ library providing a simple API to read and write INI-style configuration files"
LANGUAGES CXX
)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(IS_TOPLEVEL_PROJECT TRUE)
else()
set(IS_TOPLEVEL_PROJECT FALSE)
endif()

# Disable in-source builds:
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)

if("${srcdir}" STREQUAL "${bindir}")
message("")
message("ERROR:: in-source builds are disabled!")
message("Run cmake in a separate build directory:")
message("$ cmake -S . -B build")
message("")
message(FATAL_ERROR "Aborting...")
endif()

# Define library paths and include directories
set(EXPORT_NAMESPACE "${PROJECT_NAME}::")
set(HEADERS SimpleIni.h)

add_library(${PROJECT_NAME} INTERFACE)
add_library(${EXPORT_NAMESPACE}${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME} INTERFACE .)

0 comments on commit db0e0b2

Please sign in to comment.