]> git.lyx.org Git - features.git/commitdiff
Amend 8774ad5, Adapt to new hunspell C++ ABI for cmake
authorKornel Benko <kornel@lyx.org>
Fri, 30 Mar 2018 12:10:45 +0000 (14:10 +0200)
committerKornel Benko <kornel@lyx.org>
Fri, 30 Mar 2018 12:10:45 +0000 (14:10 +0200)
Replace CHECK_CXX_SOURCE_COMPILES() with TRY_COMPILE()
Discarding the link-stage mimics the behaviour used by automake.
Now the testsource is compiled regardless if hunspell
is external or not.

development/cmake/ConfigureChecks.cmake

index 9618d5d2ef9aef7cf5f3675c18137fb85a127720..337fbe2048a097f891bb7646e13e179e18251188 100644 (file)
@@ -73,24 +73,30 @@ check_type_size(wchar_t HAVE_WCHAR_T)
 check_type_size(wint_t  HAVE_WINT_T)
 
 # check whether hunspell C++ (rather than C) ABI is provided
-if(LYX_EXTERNAL_HUNSPELL)
-  set(CMAKE_REQUIRED_INCLUDES ${HUNSPELL_INCLUDE_DIR})
-  set(CMAKE_REQUIRED_LIBRARIES ${HUNSPELL_LIBRARY})
-  check_cxx_source_compiles(
-       "
-       #include <hunspell/hunspell.hxx>
-       int main()
-       {
-               Hunspell sp(\"foo\", \"bar\");
-               int i = sp.stem(\"test\").size();
-               return(0);
-       }
-       "
-  HAVE_HUNSPELL_CXXABI)
-else()
-  # Not compiling the 3rdparty source, because ${HUNSPELL_LIBRARY} does not exists yet to link with
-  set(HAVE_HUNSPELL_CXXABI 1 CACHE BOOL "whether hunspell C++ (rather than C) ABI is provided")
-endif()
+set(HunspellTestFile "${CMAKE_BINARY_DIR}/hunspelltest.cpp")
+file(WRITE "${HunspellTestFile}"
+"
+#include <hunspell/hunspell.hxx>
+
+int main()
+{
+  Hunspell sp(\"foo\", \"bar\");
+  int i = sp.stem(\"test\").size();
+  return(0);
+}
+"
+)
+
+try_compile(HAVE_HUNSPELL_CXXABI
+  "${CMAKE_BINARY_DIR}"
+  "${HunspellTestFile}"
+  CMAKE_FLAGS
+    "-DINCLUDE_DIRECTORIES:STRING=${HUNSPELL_INCLUDE_DIR}"
+    "-DCMAKE_CXX_LINK_EXECUTABLE='${CMAKE_COMMAD} echo not linking now...'"
+  OUTPUT_VARIABLE  LOG2)
+
+message(STATUS "HAVE_HUNSPELL_CXXABI = ${HAVE_HUNSPELL_CXXABI}")
+#message(STATUS "LOG2 = ${LOG2}")
 
 #check_cxx_source_compiles(
 #      "