parent
868ce5421e
commit
38fe488f2d
@ -0,0 +1,141 @@
|
||||
#=============================================================================
|
||||
# Copyright 2015 Luís Pereira <luis.artur.pereira@gmail.com>
|
||||
# Copyright 2015 Palo Kisa <palo.kisa@gmail.com>
|
||||
# Copyright 2013 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#=============================================================================
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Honor visibility properties for all target types.
|
||||
#
|
||||
# The ``<LANG>_VISIBILITY_PRESET`` and
|
||||
# ``VISIBILITY_INLINES_HIDDEN`` target properties affect visibility
|
||||
# of symbols during dynamic linking. When first introduced these properties
|
||||
# affected compilation of sources only in shared libraries, module libraries,
|
||||
# and executables with the ``ENABLE_EXPORTS`` property set. This
|
||||
# was sufficient for the basic use cases of shared libraries and executables
|
||||
# with plugins. However, some sources may be compiled as part of static
|
||||
# libraries or object libraries and then linked into a shared library later.
|
||||
# CMake 3.3 and above prefer to honor these properties for sources compiled
|
||||
# in all target types. This policy preserves compatibility for projects
|
||||
# expecting the properties to work only for some target types.
|
||||
#
|
||||
# The ``OLD`` behavior for this policy is to ignore the visibility properties
|
||||
# for static libraries, object libraries, and executables without exports.
|
||||
# The ``NEW`` behavior for this policy is to honor the visibility properties
|
||||
# for all target types.
|
||||
#
|
||||
# This policy was introduced in CMake version 3.3. CMake version
|
||||
# 3.3.0 warns when the policy is not set and uses ``OLD`` behavior. Use
|
||||
# the ``cmake_policy()`` command to set it to ``OLD`` or ``NEW``
|
||||
# explicitly.
|
||||
#-----------------------------------------------------------------------------
|
||||
if(COMMAND CMAKE_POLICY)
|
||||
if (POLICY CMP0063)
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#include(CheckCXXCompilerFlag)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Detect Clang compiler
|
||||
#-----------------------------------------------------------------------------
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(LXQT_COMPILER_IS_CLANGCXX 1)
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set visibility to hidden to hide symbols, unless they're exported manually
|
||||
# in the code
|
||||
#-----------------------------------------------------------------------------
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Disable exceptions
|
||||
#-----------------------------------------------------------------------------
|
||||
if (CMAKE_COMPILER_IS_GNUCXX OR LXQT_COMPILER_IS_CLANGCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Common warning flags
|
||||
#-----------------------------------------------------------------------------
|
||||
set(__LXQT_COMMON_WARNING_FLAGS "-Wall")
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Warning flags
|
||||
#-----------------------------------------------------------------------------
|
||||
if (CMAKE_COMPILER_IS_GNUCXX OR LXQT_COMPILER_IS_CLANGCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${__LXQT_COMMON_WARNING_FLAGS}")
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Linker flags
|
||||
# Do not allow undefined symbols
|
||||
#-----------------------------------------------------------------------------
|
||||
if (CMAKE_COMPILER_IS_GNUCXX OR LXQT_COMPILER_IS_CLANGCXX)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS
|
||||
"-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}"
|
||||
)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS
|
||||
"-Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# CXX11 and CXX0X requirements
|
||||
#-----------------------------------------------------------------------------
|
||||
#CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
#CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
#if(COMPILER_SUPPORTS_CXX11)
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
#elseif(COMPILER_SUPPORTS_CXX0X)
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
#else()
|
||||
# message(FATAL "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. C++11 support is required")
|
||||
#endif()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Enable exceptions for an target
|
||||
#
|
||||
# lxqt_enable_target_exceptions(<target>
|
||||
# <INTERFACE|PUBLIC|PRIVATE>
|
||||
# )
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
function(lxqt_enable_target_exceptions target mode)
|
||||
target_compile_options(${target} ${mode}
|
||||
"$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>:-fexceptions>"
|
||||
)
|
||||
endfunction()
|
@ -1,34 +1,245 @@
|
||||
#=============================================================================
|
||||
# Copyright 2015 Luís Pereira <luis.artur.pereira@gmail.com>
|
||||
#
|
||||
# Write a pkg-config pc file for given "name" with "decription"
|
||||
# Arguments:
|
||||
# name: a library name (withoud "lib" prefix and "so" suffixes
|
||||
# desc: a desription string
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
macro (create_pkgconfig_file name desc)
|
||||
set(_pkgfname "${CMAKE_CURRENT_BINARY_DIR}/${name}.pc")
|
||||
#message(STATUS "${name}: writing pkgconfig file ${_pkgfname}")
|
||||
|
||||
file(WRITE "${_pkgfname}"
|
||||
"# file generated by LXQt cmake build\n"
|
||||
"prefix=${CMAKE_INSTALL_PREFIX}\n"
|
||||
"libdir=\${prefix}/lib${LIB_SUFFIX}\n"
|
||||
"includedir=\${prefix}/include\n"
|
||||
"\n"
|
||||
"Name: ${name}\n"
|
||||
"Description: ${desc}\n"
|
||||
"Version: ${SYSSTAT_VERSION}\n"
|
||||
"Requires: Qt5Core\n"
|
||||
"Libs: -L\${libdir} -l${name}\n"
|
||||
"Cflags: -I\${includedir}\n"
|
||||
"\n"
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#=============================================================================#
|
||||
|
||||
# create_pkgconfig_file(PACKAGE_NAME <package_name>
|
||||
# VERSION <version>
|
||||
# [PREFIX <path>]
|
||||
# [EXEC_PREFIX <path>]
|
||||
# [INCLUDEDIR_PREFIX <path>]
|
||||
# [INCLUDEDIRS <path1> <path2> ... <path3>]
|
||||
# [LIBDIR_PREFIX <path>]
|
||||
# [DESCRIPTIVE_NAME <name>]
|
||||
# [DESCRIPTION <description>]
|
||||
# [URL <url>]
|
||||
# [REQUIRES <dep1> <dep2> ... <dep3>]
|
||||
# [REQUIRES_PRIVATE <dep1> <dep2> ... <dep3>]
|
||||
# [LIB_INSTALLDIR <dir>]
|
||||
# [CFLAGS <cflags>]
|
||||
# [PATH <path>]
|
||||
# [INSTALL])
|
||||
#
|
||||
#
|
||||
# PACKAGE_NAME and VERSION are mandatory. Everything else is optional
|
||||
|
||||
include(CMakeParseArguments)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
function(create_pkgconfig_file)
|
||||
set(options INSTALL)
|
||||
set(oneValueArgs
|
||||
PACKAGE_NAME
|
||||
PREFIX
|
||||
EXEC_PREFIX
|
||||
INCLUDEDIR_PREFIX
|
||||
LIBDIR_PREFIX
|
||||
DESCRIPTIVE_NAME
|
||||
DESCRIPTION
|
||||
URL
|
||||
VERSION
|
||||
PATH
|
||||
)
|
||||
set(multiValueArgs
|
||||
INCLUDEDIRS
|
||||
REQUIRES
|
||||
REQUIRES_PRIVATE
|
||||
CONFLICTS
|
||||
CFLAGS
|
||||
LIBS
|
||||
LIBS_PRIVATE
|
||||
)
|
||||
|
||||
# FreeBSD loves to install files to different locations
|
||||
# http://www.freebsd.org/doc/handbook/dirstructure.html
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
install(FILES ${_pkgfname} DESTINATION libdata/pkgconfig)
|
||||
cmake_parse_arguments(USER "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (USER_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unknown keywords given to create_pkgconfig_file(): \"${USER_UNPARSED_ARGUMENTS}\"")
|
||||
endif()
|
||||
|
||||
# Check for mandatory args. Abort if not set
|
||||
if (NOT DEFINED USER_PACKAGE_NAME)
|
||||
message(FATAL_ERROR "Required argument PACKAGE_NAME missing in generate_pkgconfig_file() call")
|
||||
else()
|
||||
set(_PKGCONFIG_PACKAGE_NAME "${USER_PACKAGE_NAME}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_VERSION)
|
||||
message(FATAL_ERROR "Required argument VERSION missing in generate_pkgconfig_file() call")
|
||||
else()
|
||||
set(_PKGCONFIG_VERSION "${USER_VERSION}")
|
||||
endif()
|
||||
|
||||
|
||||
# Optional args
|
||||
if (NOT DEFINED USER_PREFIX)
|
||||
set(_PKGCONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_EXEC_PREFIX)
|
||||
set(_PKGCONFIG_EXEC_PREFIX "\${prefix}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_INCLUDEDIR_PREFIX)
|
||||
set(_PKGCONFIG_INCLUDEDIR_PREFIX "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_LIBDIR_PREFIX)
|
||||
set(_PKGCONFIG_LIBDIR_PREFIX "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_DESCRIPTIVE_NAME)
|
||||
set(_PKGCONFIG_DESCRIPTIVE_NAME "")
|
||||
else()
|
||||
install(FILES ${_pkgfname} DESTINATION lib${LIB_SUFFIX}/pkgconfig)
|
||||
set(_PKGCONFIG_DESCRIPTIVE_NAME "${USER_DESCRIPTIVE_NAME}")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_INCLUDEDIRS)
|
||||
set(tmp "")
|
||||
foreach(dir ${USER_INCLUDEDIRS})
|
||||
if (NOT IS_ABSOLUTE "${dir}")
|
||||
list(APPEND tmp "-I\${includedir}/${dir}")
|
||||
endif()
|
||||
endforeach()
|
||||
string(REPLACE ";" " " _INCLUDEDIRS "${tmp}")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_REQUIRES)
|
||||
string(REPLACE ";" ", " _PKGCONFIG_REQUIRES "${USER_REQUIRES}")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_REQUIRES_PRIVATE)
|
||||
string(REPLACE ";" ", " _PKGCONFIG_REQUIRES_PRIVATE "${USER_REQUIRES_PRIVATE}")
|
||||
else()
|
||||
set(_PKGCONFIG_REQUIRES_PRIVATE "")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_CFLAGS)
|
||||
set(_PKGCONFIG_CFLAGS "-I\${includedir} ${_INCLUDEDIRS}")
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
if (NOT DEFINED USER_LIBS)
|
||||
set(_PKGCONFIG_LIBS "-L\${libdir}")
|
||||
else()
|
||||
set(tmp "-L\${libdir}")
|
||||
set(_libs "${USER_LIBS}")
|
||||
foreach(lib ${_libs})
|
||||
list(APPEND tmp "-l${lib}")
|
||||
endforeach()
|
||||
string(REPLACE ";" " " _PKGCONFIG_LIBS "${tmp}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_LIBS_PRIVATE)
|
||||
set(PKGCONFIG_LIBS "-L\${libdir}")
|
||||
else()
|
||||
set(tmp "")
|
||||
set(_libs "${USER_LIBS_PRIVATE}")
|
||||
foreach(lib ${_libs})
|
||||
list(APPEND tmp "-l${lib}")
|
||||
endforeach()
|
||||
string(REPLACE ";" " " _PKGCONFIG_LIBS_PRIVATE "${tmp}")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_DESCRIPTION)
|
||||
set(_PKGCONFIG_DESCRIPTION "${USER_DESCRIPTION}")
|
||||
else()
|
||||
set(_PKGCONFIG_DESCRIPTION "")
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_URL)
|
||||
set(_PKFCONFIG_URL "${USER_URL}")
|
||||
else()
|
||||
set(_PKGCONFIG_URL "")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED USER_PATH)
|
||||
set(_PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${_PKGCONFIG_PACKAGE_NAME}.pc")
|
||||
else()
|
||||
if (IS_ABSOLUTE "${USER_PATH}")
|
||||
set(_PKGCONFIG_FILE "${USER_PATH}/${_PKGCONFIG_PACKAGE_NAME}.pc")
|
||||
else()
|
||||
set(_PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${USER_PATH}/${_PKGCONFIG_PACKAGE_NAME}.pc")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Write the .pc file
|
||||
FILE(WRITE "${_PKGCONFIG_FILE}"
|
||||
"# file generated by create_pkgconfig_file()\n"
|
||||
"prefix=${_PKGCONFIG_PREFIX}\n"
|
||||
"exec_prefix=${_PKGCONFIG_EXEC_PREFIX}\n"
|
||||
"libdir=${_PKGCONFIG_LIBDIR_PREFIX}\n"
|
||||
"includedir=${_PKGCONFIG_INCLUDEDIR_PREFIX}\n"
|
||||
"\n"
|
||||
"Name: ${_PKGCONFIG_DESCRIPTIVE_NAME}\n"
|
||||
)
|
||||
|
||||
if (NOT "${_PKGCONFIG_DESCRIPTION}" STREQUAL "")
|
||||
FILE(APPEND ${_PKGCONFIG_FILE}
|
||||
"Description: ${_PKGCONFIG_DESCRIPTION}\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT "${_PKGCONFIG_URL}" STREQUAL "")
|
||||
FILE(APPEND ${_PKGCONFIG_FILE} "URL: ${_PKGCONFIG_URL}\n")
|
||||
endif()
|
||||
|
||||
FILE(APPEND ${_PKGCONFIG_FILE} "Version: ${_PKGCONFIG_VERSION}\n")
|
||||
|
||||
if (NOT "${_PKGCONFIG_REQUIRES}" STREQUAL "")
|
||||
FILE(APPEND ${_PKGCONFIG_FILE} "Requires: ${_PKGCONFIG_REQUIRES}\n")
|
||||
endif()
|
||||
|
||||
if (NOT "${_PKGCONFIG_REQUIRES_PRIVATE}" STREQUAL "")
|
||||
FILE(APPEND ${_PKGCONFIG_FILE}
|
||||
"Requires.private: ${_PKGCONFIG_REQUIRES_PRIVATE}\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
FILE(APPEND ${_PKGCONFIG_FILE}
|
||||
"Cflags: ${_PKGCONFIG_CFLAGS}\n"
|
||||
"Libs: ${_PKGCONFIG_LIBS}\n"
|
||||
)
|
||||
|
||||
if (NOT "${_PKGCONFIG_LIBS_PRIVATE}" STREQUAL "")
|
||||
FILE(APPEND ${_PKGCONFIG_FILE}
|
||||
"Libs.private: ${_PKGCONFIG_REQUIRES_PRIVATE}\n"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (DEFINED USER_INSTALL)
|
||||
# FreeBSD loves to install files to different locations
|
||||
# http://www.freebsd.org/doc/handbook/dirstructure.html
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
set(_PKGCONFIG_INSTALL_DESTINATION "libdata/pkgconfig")
|
||||
else()
|
||||
set(_PKGCONFIG_INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
endif()
|
||||
|
||||
# Make the COMPONENT an parameter ?
|
||||
install(FILES "${_PKGCONFIG_FILE}"
|
||||
DESTINATION "${_PKGCONFIG_INSTALL_DESTINATION}"
|
||||
COMPONENT Devel)
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -1 +0,0 @@
|
||||
link_directories(${SYSSTAT_LIBRARY_DIRS})
|
Loading…
Reference in new issue