-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
cmake build #105
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode | ||
build | ||
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} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No final newline. |
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} |
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}/../ | ||
) |
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
There was a problem hiding this comment.
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.