Hi,

currently FindLibical.cmake doesn't produce a proper LIBICAL_INCLUDE_DIRS
variable. That variable always contains the PATH_SUFFIX which means its
<prefix>/include/libical. However the libical headers themselves expect
only <prefix>/include to be set as include dir.

This works fine as long as one has libical installed from packages under
/usr or some other common prefix that also included in the list of
include-dirs for a project.

It breaks as soon as one installs libical to a non-common place.

The attached patch fixes that and additionally replaces the REPLACE-stuff
with TO_CMAKE_PATH (as that seems to be the intention) and also fixes the
wrong usage of find_path/find_library with NO_CMAKE_SYSTEM_PATH.

The regex-replace is ugly, but I don't know wether there are systems on
which ical.h would be directly in <prefix>/include. If we are certain that
there are no such systems we can remove the regex-replace and the
PATH_SUFFIXES and instead add libical/ to the NAMES for find_path.

Andreas

-- 
You possess a mind not merely twisted, but actually sprained.
Index: cmake/modules/FindLibical.cmake
===================================================================
--- cmake/modules/FindLibical.cmake	(Revision 917654)
+++ cmake/modules/FindLibical.cmake	(Arbeitskopie)
@@ -16,7 +16,6 @@
 
 if (WIN32)
   file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _program_FILES_DIR)
-  string(REPLACE "\\" "/" _program_FILES_DIR "${_program_FILES_DIR}")
 endif(WIN32)
 
 set(LIBICAL_FIND_REQUIRED ${Libical_FIND_REQUIRED})
@@ -28,25 +27,26 @@
 endif(LIBICAL_INCLUDE_DIRS AND LIBICAL_LIBRARIES)
 
 #set the root from the LIBICAL_BASE environment
-string(REPLACE "\\" "/" libical_root "$ENV{LIBICAL_BASE}")
+file(TO_CMAKE_PATH "$ENV{LIBICAL_BASE}" libical_root )
 #override the root from LIBICAL_BASE defined to cmake
 if(DEFINED LIBICAL_BASE)
-  string(REPLACE "\\" "/" libical_root ${LIBICAL_BASE})
+  file(TO_CMAKE_PATH "${LIBICAL_BASE}" libical_root )
 endif(DEFINED LIBICAL_BASE)
 
 find_path(LIBICAL_INCLUDE_DIRS NAMES ical.h
   PATH_SUFFIXES libical
-  PATHS ${libical_root}/include ${_program_FILES_DIR}/libical/include /usr/local/include /usr/include ${KDE4_INCLUDE_DIR}
-  NO_CMAKE_SYSTEM_PATH
+  HINTS ${libical_root}/include ${_program_FILES_DIR}/libical/include ${KDE4_INCLUDE_DIR}
 )
 
+# remove the libical suffix from the include dir
+# libical headers always use #include <libical/foo.h> so we must not have libical in this variable
+string(REGEX REPLACE "/libical$" "" LIBICAL_INCLUDE_DIRS ${LIB_ICAL_INCLUDE_DIRS})
+
 find_library(LIBICAL_LIBRARY NAMES ical libical
-  PATHS ${libical_root}/lib ${_program_FILES_DIR}/libical/lib /usr/local/lib /usr/lib ${KDE4_LIB_DIR}
-  NO_CMAKE_SYSTEM_PATH
+  HINTS ${libical_root}/lib ${_program_FILES_DIR}/libical/lib ${KDE4_LIB_DIR}
 )
 find_library(LIBICALSS_LIBRARY NAMES icalss libicalss
-  PATHS ${libical_root}/lib ${_program_FILES_DIR}/libical/lib /usr/local/lib /usr/lib ${KDE4_LIB_DIR}
-  NO_CMAKE_SYSTEM_PATH
+  HINTS ${libical_root}/lib ${_program_FILES_DIR}/libical/lib ${KDE4_LIB_DIR}
 )
 set(LIBICAL_LIBRARIES ${LIBICAL_LIBRARY} ${LIBICALSS_LIBRARY})
 
_______________________________________________
Kde-buildsystem mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-buildsystem

Reply via email to