From 0decb04cc5316c3d081d00fc13a3d85755e918fb Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Wed, 20 Feb 2008 20:26:39 +0000 Subject: -add INSTALL_TARGETS_DEFAULT_ARGS so e.g. kdepim trunk can work with kdelibs from the 4.0 branch while still being able to install correctly also on windows -allow duplicated targets, used e.g. for buildtests (for cmake 2.6 compatibility) -set CMAKE_LINK_OLD_PATHS to TRUE, so make sure linking works even if libs without full path are used (also cmake 2.6 compatiblity) Alex svn path=/branches/KDE/4.0/kdelibs/; revision=777511 --- modules/FindKDE4Internal.cmake | 51 +++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/modules/FindKDE4Internal.cmake b/modules/FindKDE4Internal.cmake index 03b0e307..e0b7bc15 100644 --- a/modules/FindKDE4Internal.cmake +++ b/modules/FindKDE4Internal.cmake @@ -487,14 +487,7 @@ set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) if (WIN32) # use relative install prefix to avoid hardcoded install paths in cmake_install.cmake files -# ok, this is more like a hack to get dll's installed into the same directory as the executables -# without having to use the full syntax of INSTALL(TARGETS ...) everywhere. -# LIB_INSTALL_DIR is set to a list of arguments, the first being the "default" destination -# which is then overridden by the following three specialized destinations - set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" - RUNTIME DESTINATION "bin" - LIBRARY DESTINATION "lib${LIB_SUFFIX}" - ARCHIVE DESTINATION "lib${LIB_SUFFIX}" ) # The subdirectory relative to the install prefix where libraries will be installed (default is ${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}) + set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" ) # The subdirectory relative to the install prefix where libraries will be installed (default is ${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}) set(EXEC_INSTALL_PREFIX "" ) # Base directory for executables and libraries set(SHARE_INSTALL_PREFIX "share" ) # Base directory for files which go to share/ @@ -600,6 +593,31 @@ else (WIN32) endif (WIN32) +# The INSTALL_TARGETS_DEFAULT_ARGS variable should be used when libraries are installed. +# The arguments are also ok for regular executables, i.e. executables which don't go +# into sbin/ or libexec/, but for installing executables the basic syntax +# INSTALL(TARGETS kate DESTINATION "${BIN_INSTALL_DIR}") +# is enough, so using this variable there doesn't help a lot. +# The variable must not be used for installing plugins. +# Usage is like this: +# install(TARGETS kdecore kdeui ${INSTALL_TARGETS_DEFAULT_ARGS} ) +# +# This will install libraries correctly under UNIX, OSX and Windows (i.e. dll's go +# into bin/. +# Later on it will be possible to extend this for installing OSX frameworks +# The COMPONENT Devel argument has the effect that static libraries belong to the +# "Devel" install component. If we use this also for all install() commands +# for header files, it will be possible to install +# -everything: make install OR cmake -P cmake_install.cmake +# -only the development files: cmake -DCOMPONENT=Devel -P cmake_install.cmake +# -everything except the development files: cmake -DCOMPONENT=Unspecified -P cmake_install.cmake +# This can then also be used for packaging with cpack. + +set(INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "${BIN_INSTALL_DIR}" + LIBRARY DESTINATION "${LIB_INSTALL_DIR}" + ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" COMPONENT Devel ) + + ############## add some more default search paths ############### # always search in the directory where cmake is installed # and in the current installation prefix @@ -634,6 +652,23 @@ if(WIN32) "${CMAKE_INSTALL_PREFIX}/bin" ) endif(WIN32) +# Differences between CMake 2.4 and 2.6 +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.4) + # CMake 2.6 gives errors if there are multiple targets with the same name + # we use this for the target "buildtests", which is created for the unit tests + # and which depends on the tests, so building "buildtests" builds all the tests + # enabling this property disables this check in CMake + set_property(GLOBAL PROPERTY ALLOW_DUPLICATE_CUSTOM_TARGETS 1) + + # CMake 2.6 uses the full file names of the libraries when linking and so + # doesn't use -L anymore to list the link dirs. Now the dependencies created + # export_library_dependencies() lists the in-project libraries without + # path, i.e. with only the logical name ("kdecore"), so they don't link + # Setting this variable to true has the effect that the link dirs are + # listed nevertheless also with CMake 2.6. + set(CMAKE_LINK_OLD_PATHS TRUE) + +endif("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.4) ##################### and now the platform specific stuff ############################ -- cgit v1.2.1 From 101adcebe1e4c82e508a345fdfd045a503e98441 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Wed, 20 Feb 2008 21:59:39 +0000 Subject: -give useful error message if a cmake cvs without set_property() is used Alex svn path=/branches/KDE/4.0/kdelibs/; revision=777553 --- modules/FindKDE4Internal.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/FindKDE4Internal.cmake b/modules/FindKDE4Internal.cmake index e0b7bc15..a0c2a0fd 100644 --- a/modules/FindKDE4Internal.cmake +++ b/modules/FindKDE4Internal.cmake @@ -654,6 +654,14 @@ endif(WIN32) # Differences between CMake 2.4 and 2.6 if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.4) + + # some developers may be using an cmake cvs version which didn't have set_property() yet + # Tell them that a more recent version is required. + if(NOT COMMAND SET_PROPERTY) + message(FATAL_ERROR "You are using an old version of CMake from cvs, please update to CMake >= 2.6.0 or cvs at least from Feb 20th, 2008") + endif(NOT COMMAND SET_PROPERTY) + + # CMake 2.6 gives errors if there are multiple targets with the same name # we use this for the target "buildtests", which is created for the unit tests # and which depends on the tests, so building "buildtests" builds all the tests -- cgit v1.2.1 From af1a7856351fa1d98b81b086116b624177647f02 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Tue, 4 Mar 2008 21:20:33 +0000 Subject: -add the cmake styleguide also in the stable branch Alex svn path=/branches/KDE/4.0/kdelibs/; revision=782340 --- modules/CMakeLists.txt | 2 +- modules/cmake-modules-styleguide.txt | 110 +++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 modules/cmake-modules-styleguide.txt diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 5de4aa7a..3df0bfca 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -4,7 +4,7 @@ file(GLOB cmakeFiles "${CMAKE_CURRENT_SOURCE_DIR}/*.cmake") set(module_install_dir ${DATA_INSTALL_DIR}/cmake/modules ) -install( FILES kde4init_dummy.cpp.in kde4_cmake_uninstall.cmake.in kde4automoc.files.in ${cmakeFiles} DESTINATION ${module_install_dir} ) +install( FILES cmake-modules-styleguide.txt kde4init_dummy.cpp.in kde4_cmake_uninstall.cmake.in kde4automoc.files.in ${cmakeFiles} DESTINATION ${module_install_dir} ) # the files listed here will be removed by remove_obsoleted_cmake_files.cmake, Alex #set(FILES_TO_REMOVE diff --git a/modules/cmake-modules-styleguide.txt b/modules/cmake-modules-styleguide.txt new file mode 100644 index 00000000..a19bceb2 --- /dev/null +++ b/modules/cmake-modules-styleguide.txt @@ -0,0 +1,110 @@ +This is a copy of the file CMake/Modules/readme.txt from cmake cvs. +Please adhere to the guidelines given below when writing cmake modules +for KDE. + +Alex + +---------------------------------------------------------------------- + +Note to authors of FindXXX.cmake files + +We would like all FindXXX.cmake files to produce consistent variable names. + +Please use the following consistent variable names for general use. + +XXX_INCLUDE_DIRS The final set of include directories listed in one variable for use by client code. This should not be a cache entry. +XXX_LIBRARIES The libraries to link against to use XXX. These should include full paths. This should not be a cache entry. +XXX_DEFINITIONS Definitions to use when compiling code that uses XXX. This really shouldn't include options such as (-DHAS_JPEG)that a client source-code file uses to decide whether to #include +XXX_EXECUTABLE Where to find the XXX tool. +XXX_YYY_EXECUTABLE Where to find the YYY tool that comes with XXX. +XXX_LIBRARY_DIRS Optionally, the final set of library directories listed in one variable for use by client code. This should not be a cache entry. +XXX_ROOT_DIR Where to find the base directory of XXX. +XXX_VERSION_YY Expect Version YY if true. Make sure at most one of these is ever true. +XXX_WRAP_YY If False, do not try to use the relevent CMake wrapping command. +XXX_YY_FOUND If False, optional YY part of XXX sytem is not available. +XXX_FOUND Set to false, or undefined, if we haven't found, or don't want to use XXX. +XXX_RUNTIME_LIBRARY_DIRS Optionally, the runtime library search path for use when running an executable linked to shared libraries. + The list should be used by user code to create the PATH on windows or LD_LIBRARY_PATH on unix. + This should not be a cache entry. +XXX_VERSION_STRING A human-readable string containing the version of the package found, if any. +XXX_VERSION_MAJOR The major version of the package found, if any. +XXX_VERSION_MINOR The minor version of the package found, if any. +XXX_VERSION_PATCH The patch version of the package found, if any. + +You do not have to provide all of the above variables. You should provide XXX_FOUND under most circumstances. If XXX is a library, then XXX_LIBRARIES, should also be defined, and XXX_INCLUDE_DIRS should usually be defined (I guess libm.a might be an exception) + +The following names should not usually be used in CMakeLists.txt files, but they may be usefully modified in users' CMake Caches to control stuff. + +XXX_LIBRARY Name of XXX Library. A User may set this and XXX_INCLUDE_DIR to ignore to force non-use of XXX. +XXX_YY_LIBRARY Name of YY library that is part of the XXX system. It may or may not be required to use XXX. +XXX_INCLUDE_DIR Where to find xxx.h, etc. (XXX_INCLUDE_PATH was considered bad because a path includes an actual filename.) +XXX_YY_INCLUDE_DIR Where to find xxx_yy.h, etc. + +For tidiness's sake, try to keep as many options as possible out of the cache, leaving at least one option which can be used to disable use of the module, or locate a not-found library (e.g. XXX_ROOT_DIR). For the same reason, mark most cache options as advanced. + +If you need other commands to do special things then it should still begin with XXX_. This gives a sort of namespace effect and keeps things tidy for the user. You should put comments describing all the exported settings, plus descriptions of any the users can use to control stuff. + +You really should also provide backwards compatibility any old settings that were actually in use. Make sure you comment them as deprecated, so that no-one starts using them. + +To correctly document a module, create a comment block at the top with # comments. There are three types of comments that can be in the block: + +1. The brief description of the module, this is done by: +# - a small description + +2. A paragraph of text. This is done with all text that has a single +space between the # and the text. To create a new paragraph, just +put a # with no text on the line. + +3. A verbatim line. This is done with two spaces between the # and the text. + +For example: + +# - This is a cool module +# This module does really cool stuff. +# It can do even more than you think. +# +# It even needs to paragraphs to tell you about it. +# And it defines the following variables: +# VAR_COOL - this is great isn't it? +# VAR_REALLY_COOL - cool right? +# + +To have a .cmake file in this directory NOT show up in the +modules documentation, you should start the file with a blank +line. + +A FindXXX.cmake module will typically be loaded by the command + + FIND_PACKAGE(XXX [major[.minor[.patch]]] [EXACT] + [QUIET] [REQUIRED [components...]]) + +If any version numbers are given to the command it will set the +variable XXX_FIND_VERSION to contain the whole version. The variables +XXX_FIND_VERSION_MAJOR, XXX_FIND_VERSION_MINOR, and +XXX_FIND_VERSION_PATCH will be set to contain the corresponding +portions of the version number. The variable XXX_FIND_VERSION_EXACT +will indicate whether an exact version is requested. +If the find module supports versioning it should locate a version of +the package that is compatible with the version requested. If a +compatible version of the package cannot be found the module should +not report success. The version of the package found should be stored +in the version variables named above. + +If the QUIET option is given to the command it will set the variable +XXX_FIND_QUIETLY to true before loading the FindXXX.cmake module. If +this variable is set the module should not complain about not being +able to find the package. If the +REQUIRED option is given to the command it will set the variable +XXX_FIND_REQUIRED to true before loading the FindXXX.cmake module. If +this variable is set the module should issue a FATAL_ERROR if the +package cannot be found. For each package-specific component, say +YYY, listed after the REQUIRED option a variable XXX_FIND_REQUIRED_YYY +to true. The set of components listed will also be specified in a +XXX_FIND_COMPONENTS variable. This can be used by the FindXXX.cmake +module to determine which sub-components of the package must be found. +If neither the QUIET nor REQUIRED options are given then the +FindXXX.cmake module should look for the package and complain without +error if the module is not found. + +To get this behaviour you can use the FIND_PACKAGE_HANDLE_STANDARD_ARGS() +macro, as an example see FindJPEG.cmake. -- cgit v1.2.1 From add74ab676ed374c6f7a735067040d1e0c8c76bd Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Tue, 4 Mar 2008 21:22:53 +0000 Subject: -add note that all-lower-case and indent-using-spaces is prefered Alex svn path=/branches/KDE/4.0/kdelibs/; revision=782342 --- modules/cmake-modules-styleguide.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/cmake-modules-styleguide.txt b/modules/cmake-modules-styleguide.txt index a19bceb2..10e65dc0 100644 --- a/modules/cmake-modules-styleguide.txt +++ b/modules/cmake-modules-styleguide.txt @@ -2,6 +2,11 @@ This is a copy of the file CMake/Modules/readme.txt from cmake cvs. Please adhere to the guidelines given below when writing cmake modules for KDE. +Some additional guidelines for use in KDE: +-indent using 2, 3 or 4 spaces, not tabs +-use all-lower-case for commands, except if the rest of the file uses +consistently all-upper-case for commands + Alex ---------------------------------------------------------------------- -- cgit v1.2.1 From e3d7adc9d5434217f69b6b42834bc08a8004b93e Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 13 Mar 2008 12:00:19 +0000 Subject: Also use pkgconfig to find QImageBlitz, since it installs a .pc file. svn path=/branches/KDE/4.0/kdelibs/; revision=785148 --- modules/FindBlitz.cmake | 12 ++++++++++++ modules/FindQImageBlitz.cmake | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/modules/FindBlitz.cmake b/modules/FindBlitz.cmake index 6f3e912b..a7aa4a14 100644 --- a/modules/FindBlitz.cmake +++ b/modules/FindBlitz.cmake @@ -1,3 +1,6 @@ +################################################################ +########## DEPRECATED, use FindQImageBlitz instead ############# +################################################################ # - Try to find blitz lib # Once done this will define # @@ -16,12 +19,20 @@ if (BLITZ_INCLUDES AND BLITZ_LIBRARIES) set(Blitz_FIND_QUIETLY TRUE) endif (BLITZ_INCLUDES AND BLITZ_LIBRARIES) +if (NOT WIN32) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + include(UsePkgConfig) + pkgconfig(qimageblitz _QIMAGEBLITZ_INCLUDEDIR _QIMAGEBLITZ_LIBDIR _dummyLinkFlags _dummyCflags) +endif (NOT WIN32) + find_path(BLITZ_INCLUDES NAMES qimageblitz.h PATH_SUFFIXES qimageblitz PATHS $ENV{QIMAGEBLITZDIR}/include + ${_QIMAGEBLITZ_INCLUDEDIR} ${KDE4_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR} ) @@ -31,6 +42,7 @@ find_library_with_debug(BLITZ_LIBRARIES qimageblitz PATHS $ENV{QIMAGEBLITZDIR}/lib + ${_QIMAGEBLITZ_LIBDIR} ${KDE4_LIB_DIR} ${LIB_INSTALL_DIR} ) diff --git a/modules/FindQImageBlitz.cmake b/modules/FindQImageBlitz.cmake index 24a5d142..978b2588 100644 --- a/modules/FindQImageBlitz.cmake +++ b/modules/FindQImageBlitz.cmake @@ -16,12 +16,20 @@ if (QIMAGEBLITZ_INCLUDES AND QIMAGEBLITZ_LIBRARIES) set(QImageBlitz_FIND_QUIETLY TRUE) endif (QIMAGEBLITZ_INCLUDES AND QIMAGEBLITZ_LIBRARIES) +if (NOT WIN32) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + include(UsePkgConfig) + pkgconfig(qimageblitz _QIMAGEBLITZ_INCLUDEDIR _QIMAGEBLITZ_LIBDIR _dummyLinkFlags _dummyCflags) +endif (NOT WIN32) + find_path(QIMAGEBLITZ_INCLUDES NAMES qimageblitz.h PATH_SUFFIXES qimageblitz PATHS $ENV{QIMAGEBLITZDIR}/include + ${_QIMAGEBLITZ_INCLUDEDIR} ${KDE4_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR} ) @@ -31,6 +39,7 @@ find_library_with_debug(QIMAGEBLITZ_LIBRARIES qimageblitz PATHS $ENV{QIMAGEBLITZDIR}/lib + ${_QIMAGEBLITZ_LIBDIR} ${KDE4_LIB_DIR} ${LIB_INSTALL_DIR} ) -- cgit v1.2.1