forked from ariadne/pkgconf
Tidy up a bit.
parent
0ba391bc6f
commit
794aa5016a
|
@ -1,11 +1,46 @@
|
||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1)
|
# CMake configuration for pkgconf
|
||||||
|
#
|
||||||
|
# Caution: this assumes you don't set CMAKE_BUILD_TYPE
|
||||||
|
#
|
||||||
|
# FIXME: this isn't a native cmake approach, it's just a straight translation
|
||||||
|
# of configure.ac + Makefile.am, barely good enough to work on Linux, Mac, and Windows.
|
||||||
|
|
||||||
|
# Require recent cmake, but not so recent that Ubuntu 16.04 users have to upgrade.
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1 FATAL_ERROR)
|
||||||
|
|
||||||
PROJECT(pkgconf C)
|
PROJECT(pkgconf C)
|
||||||
|
|
||||||
SET(PACKAGE_BUGREPORT http://github.com/pkgconf/pkgconf/issues)
|
SET(PACKAGE_BUGREPORT http://github.com/pkgconf/pkgconf/issues)
|
||||||
SET(PACKAGE_NAME pkgconf)
|
SET(PACKAGE_NAME pkgconf)
|
||||||
SET(PACKAGE_VERSION 1.3.7)
|
SET(PACKAGE_VERSION 1.3.7)
|
||||||
|
SET(LIBPKGCONF_VERSION "2.0.0")
|
||||||
|
SET(LIBPKGCONF_SOVERSION 2)
|
||||||
|
|
||||||
|
#-------- GNU directory variables ---------
|
||||||
|
|
||||||
|
SET(abs_top_srcdir ${pkgconf_SOURCE_DIR})
|
||||||
|
SET(prefix ${CMAKE_INSTALL_PREFIX})
|
||||||
|
SET(exec_prefix ${prefix})
|
||||||
|
SET(datarootdir ${prefix}/share)
|
||||||
|
SET(datadir ${datarootdir})
|
||||||
|
SET(libdir ${prefix}/lib)
|
||||||
|
SET(includedir ${prefix}/include)
|
||||||
|
|
||||||
|
#-------- User-settable options ---------
|
||||||
|
|
||||||
|
# FIXME: this is overridden in get_default_pkgconfig_path() on windows, but not in test_env.sh.in?!
|
||||||
|
SET(pkg_config_dir "${libdir}/pkgconfig:${datadir}/pkgconfig" CACHE STRING "specify the places where pc files will be found")
|
||||||
|
SET(PKGCONFIGDIR "${pkg_config_dir}")
|
||||||
|
SET(pkg_default_dir "${PKGCONFIGDIR}") # c'mon, make up your mind
|
||||||
|
|
||||||
|
SET(system_libdir "${libdir}" CACHE STRING "specify the system library directory (default LIBDIR)")
|
||||||
|
SET(SYSTEM_LIBDIR "${system_libdir}")
|
||||||
|
|
||||||
|
SET(system_includedir "${includedir}" CACHE STRING "specify the system include directory (default INCLUDEDIR)")
|
||||||
|
SET(SYSTEM_INCLUDEDIR "${system_includedir}")
|
||||||
|
|
||||||
|
#-------- Probe system ---------
|
||||||
|
|
||||||
# Expand config.h
|
|
||||||
INCLUDE (CheckIncludeFiles)
|
INCLUDE (CheckIncludeFiles)
|
||||||
CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H)
|
CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H)
|
||||||
INCLUDE (CheckFunctionExists)
|
INCLUDE (CheckFunctionExists)
|
||||||
|
@ -13,17 +48,12 @@ CHECK_FUNCTION_EXISTS(strlcpy HAVE_STRLCPY)
|
||||||
CHECK_FUNCTION_EXISTS(strlcat HAVE_STRLCAT)
|
CHECK_FUNCTION_EXISTS(strlcat HAVE_STRLCAT)
|
||||||
CHECK_FUNCTION_EXISTS(strndup HAVE_STRNDUP)
|
CHECK_FUNCTION_EXISTS(strndup HAVE_STRNDUP)
|
||||||
CHECK_FUNCTION_EXISTS(cygwin_conv_path HAVE_CYGWIN_CONV_PATH)
|
CHECK_FUNCTION_EXISTS(cygwin_conv_path HAVE_CYGWIN_CONV_PATH)
|
||||||
SET(abs_top_srcdir ${pkgconf_SOURCE_DIR})
|
|
||||||
SET(prefix ${CMAKE_INSTALL_PREFIX})
|
#-------- Generate source files ---------
|
||||||
SET(exec_prefix ${CMAKE_INSTALL_PREFIX})
|
|
||||||
SET(datarootdir ${CMAKE_INSTALL_PREFIX}/share)
|
|
||||||
SET(libdir ${CMAKE_INSTALL_PREFIX}/lib)
|
|
||||||
SET(PKGCONFIGDIR "${libdir}/pkgconfig:${datarootdir}/pkgconfig")
|
|
||||||
CONFIGURE_FILE(libpkgconf/config.h.cmake.in libpkgconf/config.h @ONLY)
|
CONFIGURE_FILE(libpkgconf/config.h.cmake.in libpkgconf/config.h @ONLY)
|
||||||
# Handy that these files need configuring; cygwin atf doesn't like windows line endings, and NEWLINE_STYLE helps.
|
|
||||||
FOREACH(file Kyuafile tests/Kyuafile tests/test_env.sh)
|
#-------- Configure common compiler options --------
|
||||||
CONFIGURE_FILE(${file}.in ${file} @ONLY NEWLINE_STYLE UNIX)
|
|
||||||
ENDFOREACH()
|
|
||||||
|
|
||||||
IF (WIN32)
|
IF (WIN32)
|
||||||
# Make warnings fatal... but ignore C4996: 'strdup' two different ways
|
# Make warnings fatal... but ignore C4996: 'strdup' two different ways
|
||||||
|
@ -31,25 +61,36 @@ IF (WIN32)
|
||||||
# Ignore warning C4996: 'strncpy'
|
# Ignore warning C4996: 'strncpy'
|
||||||
ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS=1")
|
ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS=1")
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -std=gnu99")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -std=gnu99 -O2 -g")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${pkgconf_SOURCE_DIR} ${pkgconf_BINARY_DIR})
|
INCLUDE_DIRECTORIES(${pkgconf_SOURCE_DIR} ${pkgconf_BINARY_DIR})
|
||||||
ADD_DEFINITIONS(-DPKG_DEFAULT_PATH=\"$(pkg_default_dir)\")
|
ADD_DEFINITIONS(-DPKG_DEFAULT_PATH=\"${pkg_default_dir}\")
|
||||||
ADD_DEFINITIONS(-DSYSTEM_INCLUDEDIR=\"$(system_includedir)\")
|
ADD_DEFINITIONS(-DSYSTEM_INCLUDEDIR=\"${system_includedir}\")
|
||||||
ADD_DEFINITIONS(-DSYSTEM_LIBDIR=\"$(system_libdir)\")
|
ADD_DEFINITIONS(-DSYSTEM_LIBDIR=\"${system_libdir}\")
|
||||||
|
|
||||||
|
#-------- Build and install library --------
|
||||||
|
|
||||||
# Place shared libraries in same place as binary, for ease of setting PATH in test_env.sh
|
# Place shared libraries in same place as binary, for ease of setting PATH in test_env.sh
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${pkgconf_BINARY_DIR})
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${pkgconf_BINARY_DIR})
|
||||||
ADD_SUBDIRECTORY(libpkgconf)
|
ADD_SUBDIRECTORY(libpkgconf)
|
||||||
|
|
||||||
|
#-------- Build and install executable --------
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${libpkgconf_BINARY_DIR})
|
INCLUDE_DIRECTORIES(${libpkgconf_BINARY_DIR})
|
||||||
ADD_EXECUTABLE(pkgconf main.c getopt_long.c)
|
ADD_EXECUTABLE(pkgconf main.c getopt_long.c)
|
||||||
TARGET_LINK_LIBRARIES(pkgconf libpkgconf)
|
TARGET_LINK_LIBRARIES(pkgconf libpkgconf)
|
||||||
INSTALL(TARGETS pkgconf DESTINATION bin)
|
INSTALL(TARGETS pkgconf DESTINATION bin)
|
||||||
|
|
||||||
|
#-------- Tests ---------
|
||||||
|
|
||||||
ENABLE_TESTING()
|
ENABLE_TESTING()
|
||||||
|
|
||||||
|
# Handy that these files need configuring; cygwin atf doesn't like windows line endings, and NEWLINE_STYLE helps.
|
||||||
|
FOREACH(file Kyuafile tests/Kyuafile tests/test_env.sh)
|
||||||
|
CONFIGURE_FILE(${file}.in ${file} @ONLY NEWLINE_STYLE UNIX)
|
||||||
|
ENDFOREACH()
|
||||||
|
|
||||||
SET(test_scripts
|
SET(test_scripts
|
||||||
tests/basic
|
tests/basic
|
||||||
tests/builtins
|
tests/builtins
|
||||||
|
|
|
@ -18,7 +18,7 @@ ADD_LIBRARY(libpkgconf SHARED
|
||||||
queue.c
|
queue.c
|
||||||
tuple.c
|
tuple.c
|
||||||
)
|
)
|
||||||
SET_TARGET_PROPERTIES(libpkgconf PROPERTIES VERSION "2.0.0" SOVERSION 2)
|
SET_TARGET_PROPERTIES(libpkgconf PROPERTIES VERSION ${LIBPKGCONF_VERSION} SOVERSION ${LIBPKGCONF_SOVERSION})
|
||||||
INSTALL(TARGETS libpkgconf
|
INSTALL(TARGETS libpkgconf
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
|
|
Loading…
Reference in New Issue