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

cmake build #105

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
build
Comment on lines +1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing that should be in an upstream git repo IMHO.

49 changes: 49 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.15)
project(INIH)


add_library(inih ini.c)

add_library(INIReader ini.c cpp/INIReader.cpp)

enable_testing()
add_subdirectory(examples)

add_test(NAME test_inihc
COMMAND bash unittest.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests
)

if(UNIX)
include(GNUInstallDirs)
set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(prefix ${CMAKE_INSTALL_PREFIX})
configure_file(inih.pc.in inih.pc @ONLY)
configure_file(INIReader.pc.in INIReader.pc @ONLY)

install(TARGETS inih INIReader
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't entirely get why there needs a bindir needs to be set.

LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
# message(STATUS "lib:${CMAKE_INSTALL_FULL_LIBDIR}:${CMAKE_INSTALL_BINDIR}")
install(FILES ${PROJECT_BINARY_DIR}/inih.pc ${PROJECT_BINARY_DIR}/INIReader.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)

install(FILES ini.h cpp/INIReader.h
TYPE INCLUDE
)
endif()

if(WIN32)
install(FILES ini.h cpp/INIReader.h
TYPE INCLUDE
)
install(TARGETS inih INIReader
RUNTIME DESTINATION bin/$<CONFIG>
LIBRARY DESTINATION lib/$<CONFIG>
ARCHIVE DESTINATION lib/$<CONFIG>
)
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No final newline.

12 changes: 12 additions & 0 deletions INIReader.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=${prefix}
libdir=@libdir@
includedir=@includedir@

Name: INIReader
Version: @PACKAGE_VERSION@
Description: ZeroMQ libuv.
URL: https://github.com/MerlinXYoung/inih

Libs: -L${libdir} -lINIReader @LIBS@
Cflags: -I${includedir}
19 changes: 19 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


file(GLOB SRCS "*.c")

foreach(SRC ${SRCS})
message(STATUS "SRC ${SRC}")
string(REGEX REPLACE ".c$" "" TAG ${SRC})
string(REGEX REPLACE ".*/" "" TAG ${TAG})
message(STATUS "TAG ${TAG}")
add_executable(${TAG} ${SRC})
target_link_libraries(${TAG} inih)
endforeach(SRC ${SRCS})

add_executable(INIReaderExample INIReaderExample.cpp)
target_link_libraries(INIReaderExample INIReader)

add_test(NAME test_inih COMMAND ./examples/INIReaderExample
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../
)
12 changes: 12 additions & 0 deletions inih.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=${prefix}
libdir=@libdir@
includedir=@includedir@

Name: inih
Version: @PACKAGE_VERSION@
Description: ZeroMQ libuv.
URL: https://github.com/MerlinXYoung/inih

Libs: -L${libdir} -linih @LIBS@
Cflags: -I${includedir}
Comment on lines +1 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg-config files are already created by Meson, no need to add them to CMake.