cmake: split out FindEnchant.cmake

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@34928 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Peter Kümmel 2010-07-17 11:04:05 +00:00
parent 8383ec013f
commit d0db7a9954
4 changed files with 54 additions and 22 deletions

View File

@ -35,6 +35,7 @@ message(STATUS)
LYX_OPTION(NLS "Use nls" OFF ALL)
LYX_OPTION(ASPELL "Require aspell" OFF ALL)
LYX_OPTION(AIKSAURUS "Require Aiksaurus" OFF ALL)
LYX_OPTION(ENCHANT "Require Enchant" OFF ALL)
LYX_OPTION(DEBUG "Build debug version" OFF ALL)
LYX_OPTION(RELEASE "Build release version" ON ALL)
LYX_OPTION(PROFILE "Build profile version" OFF GCC)
@ -248,11 +249,16 @@ if(LYX_ASPELL)
include_directories(${ASPELL_INCLUDE_DIR})
endif()
if (LYX_AIKSAURUS)
if(LYX_AIKSAURUS)
find_package(AiksaurusLIB REQUIRED)
include_directories(${AIKSAURUSLIB_INCLUDE_DIR})
endif()
if(LYX_ENCHANT)
find_package(Enchant REQUIRED)
include_directories(${ENCHANT_INCLUDE_DIR})
endif()
@ -263,23 +269,7 @@ endif()
# TODO make Find*.cmake
if(WIN32)
find_library(ENCHANT_LIBRARY "libenchant")
find_path(ENCHANT_INCLUDE_DIR "enchant++.h")
else()
find_library(ENCHANT_LIBRARY "enchant" "/usr/local/lib" "/usr/lib" "/usr/local/lib" "/opt/local/lib")
find_path(ENCHANT_INCLUDE_DIR "enchant++.h" PATHS /usr/local/include /usr/local/include/enchant /usr/include /usr/include/enchant /opt/local/include/enchant)
endif()
if (ENCHANT_LIBRARY AND ENCHANT_INCLUDE_DIR)
set(ENCHANT_FOUND TRUE)
add_definitions(-DUSE_ENCHANT=1)
message(STATUS "Building with USE_ENCHANT")
else()
message(STATUS "Enchant not found, building without enchant support")
endif()
if (ENCHANT_FOUND)
include_directories("${ENCHANT_INCLUDE_DIR}")
endif()
if(LYX_NLS)
@ -287,7 +277,6 @@ if(LYX_NLS)
endif()
if(WIN32)
if(LYX_NO_CONSOLE)
set(WIN32_CONSOLE WIN32)

View File

@ -47,19 +47,26 @@
#define USE_ASPELL 1
#endif
#cmakedefine AIKSAURUSLIB_FOUND 1
#ifdef AIKSAURUSLIB_FOUND
#define HAVE_LIBAIKSAURUS 1
#define AIKSAURUS_H_LOCATION "${AIKSAURUSLIB_H}"
#endif
#cmakedefine ENCHANT_FOUND 1
#ifdef ENCHANT_FOUND
#define USE_ENCHANT 1
#endif
// cleanup global namespace
#endif // config.h guard
// Ungruaded cleanup of global namespace:
#ifdef ColorMode
#undef ColorMode
#endif

View File

@ -0,0 +1,36 @@
if(WIN32)
find_library(ENCHANT_LIBRARY "libenchant")
find_path(ENCHANT_INCLUDE_DIR "enchant++.h")
else()
find_library(ENCHANT_LIBRARY "enchant"
"/usr/local/lib"
"/usr/lib"
"/usr/local/lib"
"/opt/local/lib")
find_path(ENCHANT_INCLUDE_DIR "enchant++.h" PATHS
/usr/local/include
/usr/local/include/enchant
/usr/include
/usr/include/enchant
/opt/local/include/enchant)
endif()
if (ENCHANT_LIBRARY AND ENCHANT_INCLUDE_DIR)
set(ENCHANT_FOUND TRUE)
add_definitions(-DUSE_ENCHANT=1)
message(STATUS "Building with USE_ENCHANT")
else()
message(STATUS "Enchant not found, building without enchant support")
endif()
# handle the QUIETLY and REQUIRED arguments and
# set ENCHANT_FOUND to TRUE if all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ENCHANT DEFAULT_MSG ENCHANT_LIBRARY ENCHANT_INCLUDE_DIR)
if(Enchant_FIND_REQUIRED AND NOT ENCHANT_FOUND)
message(FATAL_ERROR "Could not find Enchant library")
endif()
mark_as_advanced(ENCHANT_LIBRARY ENCHANT_INCLUDE_DIR)

View File

@ -98,7 +98,7 @@ if (ASPELL_FOUND)
endif()
if (ENCHANT_FOUND)
target_link_libraries(${_lyx} ${ENCHANT_LIBRARY})
target_link_libraries(${_lyx} ${ENCHANT_LIBRARY})
endif()
if (AIKSAURUSLIB_FOUND)