Hi again,

now we seem to have confused you entirely, sorry :(
Attached is a quick hacked-together patch. I compiled qjson, but I
didn't compile anything against it because it should be reviewed anyway
(and that would require me somehow crafting a debian package for this
version). It's essentially taken from the commits
69676d4564504c3f488b430e48666176e0e3d0c8 and
6abb5217acb18b59dc0f79e59475a4f4c483933a in master. Someone knowing
cmake better than me should have a look...

Lisandro suggested I should try to explain the problem again - okay, let
me try. I'll use KDE as example as that's where I saw it.
KDE uses find_package(QJSON) and then uses the variables
QJSON_INCLUDE_DIR and QJSON_LIBRARIES. That works all right with qjson
0.7.1. Then FindQJSON.cmake was dropped in libqjson master, and some
-config.cmake files were installed instead
(69676d4564504c3f488b430e48666176e0e3d0c8). That patch was backported to
Debian, but never released in qjson. And that patch breaks apps, because
KDE (somehow) still finds these files, but now the variables are called
qjson_INCLUDE_DIR and qjson_LIBRARIES (and they are case sensitive). For
that reason, 6abb5217acb18b59dc0f79e59475a4f4c483933a was committed in
qjson, but that one never arrived in Debian. Now KDE uses
"${QJSON_INCLUDE_DIR} ${qjson_INCLUDE_DIR}", which is of course a hack -
I added it to kde-workspace and just saw it's in kdepimlibs now as well.
Debian is nearing its next stable release, and IMHO it would be really
unfortunate to release it with a qqjson "cmake interace" (or however one
wants to call this collection of config files) incompatible with the
rest of the world. Therefore, we'd like to patch Debian to use the
interface the next major release of qjson will use, and we asked for
your assistance to be sure that this is indeed the case :)

I hope this clears things up. Thanks for your patience.
Ralf
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4ed5478..7b9dcb5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,12 +39,12 @@ SET( QT_DONT_USE_QTGUI TRUE )
 SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
 SET (LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING 
"Directory where lib will install")
 SET (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The 
directory the headers are installed in")
-SET (CMAKE_MODULES_INSTALL_DIR 
"${CMAKE_INSTALL_PREFIX}/share/apps/cmake/modules" CACHE PATH "The directory to 
install FindQRpc.cmake to")
+SET (CMAKECONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${CMAKE_PROJECT_NAME}" 
CACHE PATH "Directory where to install QJSONConfig.cmake")
 
 
 set(QJSON_LIB_MAJOR_VERSION "0")
 set(QJSON_LIB_MINOR_VERSION "7")
-set(QJSON_LIB_PATCH_VERSION "1")
+set(QJSON_LIB_PATCH_VERSION "2")
 
 set(QJSON_LIB_VERSION_STRING 
"${QJSON_LIB_MAJOR_VERSION}.${QJSON_LIB_MINOR_VERSION}.${QJSON_LIB_PATCH_VERSION}")
 
@@ -69,13 +69,24 @@ IF (KDE4_BUILD_TESTS OR QJSON_BUILD_TESTS)
   ADD_SUBDIRECTORY(tests)
 ENDIF (KDE4_BUILD_TESTS OR QJSON_BUILD_TESTS)
 
-add_subdirectory(cmake/modules)
-
 
 #CONFIGURE_FILE(
 #  "${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in"
 #  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
 #  IMMEDIATE @ONLY)
 
+INSTALL(EXPORT qjson-export DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE 
QJSONTargets.cmake)
+
+# cmake-modules
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/QJSONConfig.cmake.in
+               ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfig.cmake
+               @ONLY)
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/QJSONConfigVersion.cmake.in
+               ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfigVersion.cmake
+               @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfig.cmake
+              ${CMAKE_CURRENT_BINARY_DIR}/QJSONConfigVersion.cmake
+        DESTINATION "${CMAKECONFIG_INSTALL_DIR}")
+
 #ADD_CUSTOM_TARGET(uninstall
 #  "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
deleted file mode 100644
index ff51311..0000000
--- a/cmake/modules/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-set(cmakeFiles FindQJSON.cmake)
-install(FILES ${cmakeFiles} DESTINATION ${CMAKE_MODULES_INSTALL_DIR})
diff --git a/cmake/modules/FindQJSON.cmake b/cmake/modules/FindQJSON.cmake
deleted file mode 100644
index 32e294f..0000000
--- a/cmake/modules/FindQJSON.cmake
+++ /dev/null
@@ -1,46 +0,0 @@
-# Find QJSON - JSON handling library for Qt
-#
-# This module defines
-#  QJSON_FOUND - whether the qsjon library was found
-#  QJSON_LIBRARIES - the qjson library
-#  QJSON_INCLUDE_DIR - the include path of the qjson library
-#
-
-if (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES)
-
-  # Already in cache
-  set (QJSON_FOUND TRUE)
-
-else (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES)
-
-  if (NOT WIN32)
-    # use pkg-config to get the values of QJSON_INCLUDE_DIRS
-    # and QJSON_LIBRARY_DIRS to add as hints to the find commands.
-    include (FindPkgConfig)
-    pkg_check_modules (QJSON REQUIRED QJson>=0.5)
-  endif (NOT WIN32)
-
-  find_library (QJSON_LIBRARIES
-    NAMES
-    qjson
-    PATHS
-    ${QJSON_LIBRARY_DIRS}
-    ${LIB_INSTALL_DIR}
-    ${KDE4_LIB_DIR}
-  )
-
-  find_path (QJSON_INCLUDE_DIR
-    NAMES
-    parser.h
-    PATH_SUFFIXES
-    qjson
-    PATHS
-    ${QJSON_INCLUDE_DIRS}
-    ${INCLUDE_INSTALL_DIR}
-    ${KDE4_INCLUDE_DIR}
-  )
-
-  include(FindPackageHandleStandardArgs)
-  find_package_handle_standard_args(QJSON DEFAULT_MSG QJSON_LIBRARIES 
QJSON_INCLUDE_DIR)
-
-endif (QJSON_INCLUDE_DIR AND QJSON_LIBRARIES)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ced213d..9ae5892 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -35,7 +35,7 @@ set_target_properties(qjson PROPERTIES
                       DEFINE_SYMBOL QJSON_MAKEDLL
                       )
 
-INSTALL(TARGETS qjson
+INSTALL(TARGETS qjson EXPORT qjson-export
    LIBRARY DESTINATION ${LIB_INSTALL_DIR}
    RUNTIME DESTINATION bin
    ARCHIVE DESTINATION  ${LIB_INSTALL_DIR}

Reply via email to