2006-09-15 17:05:20 +00:00
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
#
# Copyright (c) 2006, Peter K<> mmel, <syntheticpp@gmx.net>
#
2006-06-11 11:57:25 +00:00
include ( CheckIncludeFile )
include ( CheckIncludeFileCXX )
include ( CheckIncludeFiles )
include ( CheckSymbolExists )
include ( CheckFunctionExists )
include ( CheckLibraryExists )
include ( CheckTypeSize )
include ( CheckCXXSourceCompiles )
2016-07-10 17:31:32 +00:00
include ( CheckCXXSourceRuns )
2008-04-20 11:06:08 +00:00
include ( MacroBoolTo01 )
2008-09-20 19:43:52 +00:00
include ( TestBigEndian )
2006-06-11 11:57:25 +00:00
2008-09-20 19:43:52 +00:00
test_big_endian ( WORDS_BIGENDIAN )
2006-06-11 11:57:25 +00:00
2007-08-23 21:18:53 +00:00
#check_include_file_cxx(istream HAVE_ISTREAM)
#check_include_file_cxx(ostream HAVE_OSTREAM)
#check_include_file_cxx(sstream HAVE_SSTREAM)
2013-02-12 18:01:16 +00:00
#check_include_file_cxx(ios HAVE_IOS)
2007-08-23 21:18:53 +00:00
#check_include_file_cxx(locale HAVE_LOCALE)
2006-06-11 11:57:25 +00:00
2013-02-12 18:01:16 +00:00
# defines will be written to configIncludes.h
set ( Include_Defines )
foreach ( _h_file aspell.h aspell/aspell.h limits.h locale.h
s t d l i b . h s y s / s t a t . h s y s / t i m e . h s y s / t y p e s . h s y s / u t i m e . h
s y s / s o c k e t . h u n i s t d . h i n t t y p e s . h u t i m e . h s t r i n g . h a r g z . h )
string ( REGEX REPLACE "[/\\.]" "_" _hf ${ _h_file } )
string ( TOUPPER ${ _hf } _HF )
check_include_files ( ${ _h_file } HAVE_ ${ _HF } )
set ( Include_Defines "${Include_Defines}#cmakedefine HAVE_${_HF} 1\n" )
endforeach ( )
2015-12-06 19:04:21 +00:00
check_include_file_cxx ( regex HAVE_REGEX )
set ( Include_Defines "${Include_Defines}#cmakedefine HAVE_REGEX 1\n" )
2013-02-12 18:01:16 +00:00
configure_file ( ${ LYX_CMAKE_DIR } /configIncludes.cmake ${ TOP_BINARY_DIR } /configIncludes.h.cmake )
configure_file ( ${ TOP_BINARY_DIR } /configIncludes.h.cmake ${ TOP_BINARY_DIR } /configIncludes.h )
2006-06-11 11:57:25 +00:00
2013-02-12 18:01:16 +00:00
# defines will be written to configFunctions.h
2013-02-12 16:22:07 +00:00
set ( Function_Defines )
2013-02-12 14:27:39 +00:00
foreach ( _f alloca __argz_count __argz_next __argz_stringify
c h m o d c l o s e _ c l o s e d c g e t t e x t f c n t l f o r k _ _ f s e t l o c k i n g
2013-11-20 18:40:32 +00:00
g e t c w d g e t e g i d g e t g i d g e t p i d _ g e t p i d g e t t e x t g e t u i d l s t a t l o c k f m e m p c p y m k d i r _ m k d i r
2013-02-12 14:27:39 +00:00
m k f i f o o p e n _ o p e n p c l o s e _ p c l o s e p o p e n _ p o p e n p u t e n v r e a d l i n k
s e t e n v s e t l o c a l e s t r c a s e c m p s t p c p y s t r d u p s t r e r r o r s t r t o u l t s e a r c h u n s e t e n v w c s l e n )
string ( TOUPPER ${ _f } _UF )
check_function_exists ( ${ _f } HAVE_ ${ _UF } )
2013-02-12 16:22:07 +00:00
set ( Function_Defines "${Function_Defines}#cmakedefine HAVE_${_UF} 1\n" )
2013-02-12 14:27:39 +00:00
endforeach ( )
2013-02-12 18:01:16 +00:00
configure_file ( ${ LYX_CMAKE_DIR } /configFunctions.cmake ${ TOP_BINARY_DIR } /configFunctions.h.cmake )
configure_file ( ${ TOP_BINARY_DIR } /configFunctions.h.cmake ${ TOP_BINARY_DIR } /configFunctions.h )
2006-06-11 11:57:25 +00:00
2006-08-14 08:59:30 +00:00
check_symbol_exists ( alloca "malloc.h" HAVE_SYMBOL_ALLOCA )
2006-06-11 11:57:25 +00:00
check_symbol_exists ( asprintf "stdio.h" HAVE_ASPRINTF )
check_symbol_exists ( wprintf "stdio.h" HAVE_WPRINTF )
check_symbol_exists ( snprintf "stdio.h" HAVE_SNPRINTF )
check_symbol_exists ( printf "stdio.h" HAVE_POSIX_PRINTF )
check_symbol_exists ( pid_t "sys/types.h" HAVE_PID_T )
check_symbol_exists ( intmax_t "inttypes.h" HAVE_INTTYPES_H_WITH_UINTMAX )
check_symbol_exists ( uintmax_t "stdint.h" HAVE_STDINT_H_WITH_UINTMAX )
check_symbol_exists ( LC_MESSAGES "locale.h" HAVE_LC_MESSAGES )
2016-06-12 17:56:31 +00:00
check_symbol_exists ( PATH_MAX "limits.h" HAVE_DEF_PATH_MAX )
2006-06-11 11:57:25 +00:00
check_type_size ( intmax_t HAVE_INTMAX_T )
2008-04-20 11:06:08 +00:00
macro_bool_to_01 ( HAVE_UINTMAX_T HAVE_STDINT_H_WITH_UINTMAX )
2006-06-11 11:57:25 +00:00
check_type_size ( "long double" HAVE_LONG_DOUBLE )
check_type_size ( "long long" HAVE_LONG_LONG )
check_type_size ( wchar_t HAVE_WCHAR_T )
check_type_size ( wint_t HAVE_WINT_T )
2018-03-30 17:40:08 +00:00
if ( HUNSPELL_FOUND )
# check whether hunspell C++ (rather than C) ABI is provided
set ( HunspellTestFile "${CMAKE_BINARY_DIR}/hunspelltest.cpp" )
file ( WRITE "${HunspellTestFile}"
"
#include <hunspell/hunspell.hxx>
i n t main ( )
{
H u n s p e l l sp ( \"foo\", \"bar\");
i n t i = s p . stem ( \"test\").size();
2018-03-30 12:10:45 +00:00
return ( 0 ) ;
2018-03-30 17:40:08 +00:00
}
"
)
try_compile ( HAVE_HUNSPELL_CXXABI
" $ { C M A K E _ B I N A R Y _ D I R } "
" $ { H u n s p e l l T e s t F i l e } "
C M A K E _ F L A G S
" - D I N C L U D E _ D I R E C T O R I E S : S T R I N G = $ { H U N S P E L L _ I N C L U D E _ D I R } "
" - D C M A K E _ C X X _ L I N K _ E X E C U T A B L E = ' $ { C M A K E _ C O M M A D } e c h o n o t l i n k i n g n o w . . . ' "
2018-03-30 12:10:45 +00:00
O U T P U T _ V A R I A B L E L O G 2 )
2018-03-30 17:40:08 +00:00
message ( STATUS "HAVE_HUNSPELL_CXXABI = ${HAVE_HUNSPELL_CXXABI}" )
#message(STATUS "LOG2 = ${LOG2}")
2018-04-09 15:13:52 +00:00
if ( LYX_EXTERNAL_HUNSPELL AND LYX_STDLIB_DEBUG AND HAVE_HUNSPELL_CXXABI )
message ( WARNING "Compiling LyX with stdlib-debug and system hunspell libraries may lead to crashes. Consider using -DLYX_STDLIB_DEBUG=OFF or -DLYX_EXTERNAL_HUNSPELL=OFF." )
endif ( )
2018-03-30 17:40:08 +00:00
endif ( )
2006-06-11 11:57:25 +00:00
2007-08-23 21:18:53 +00:00
#check_cxx_source_compiles(
# "
# #include <algorithm>
# using std::count;
# int countChar(char * b, char * e, char const c)
# {
# return count(b, e, c);
# }
# int main(){return 0;}
# "
#HAVE_STD_COUNT)
#check_cxx_source_compiles(
# "
# #include <cctype>
# using std::tolower;
# int main(){return 0;}
# "
#CXX_GLOBAL_CSTD)
2006-06-11 11:57:25 +00:00
2007-08-10 15:09:34 +00:00
check_cxx_source_compiles (
"
#include <iconv.h>
/ / t h i s d e c l a r a t i o n w i l l f a i l w h e n t h e r e a l r e a d y e x i s t s a n o n c o n s t c h a r * * v e r s i o n w h i c h r e t u r n s s i z e _ t
d o u b l e iconv ( iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft ) ;
i n t main ( ) { r e t u r n 0 ; }
"
H A V E _ I C O N V _ C O N S T )
2006-08-14 16:38:04 +00:00
2006-09-13 21:45:52 +00:00
check_cxx_source_compiles (
"
i n t i [ ( sizeof ( wchar_t ) = = 2 ? 1 : - 1 ) ] ;
i n t main ( ) { r e t u r n 0 ; }
"
S I Z E O F _ W C H A R _ T _ I S _ 2 )
check_cxx_source_compiles (
"
i n t i [ ( sizeof ( wchar_t ) = = 4 ? 1 : - 1 ) ] ;
i n t main ( ) { r e t u r n 0 ; }
"
S I Z E O F _ W C H A R _ T _ I S _ 4 )
2016-05-05 11:05:12 +00:00
check_cxx_source_compiles (
"
i n t i [ ( sizeof ( long long ) > sizeof ( long ) ? 1 : - 1 ) ] ;
i n t main ( ) { r e t u r n 0 ; }
"
S I Z E O F _ L O N G _ L O N G _ G R E A T E R _ T H A N _ S I Z E O F _ L O N G )
2014-11-09 11:59:14 +00:00
check_cxx_source_compiles (
"
#include <execinfo.h>
#include <cxxabi.h>
i n t main ( ) {
v o i d * a r r a y [ 2 0 0 ] ;
s i z e _ t s i z e = backtrace ( array, 200 ) ;
backtrace_symbols ( array, size ) ;
i n t s t a t u s = 0 ;
a b i : : __cxa_demangle ( \"abcd\", 0, 0, &status ) ;
}
"
L Y X _ C A L L S T A C K _ P R I N T I N G )
2014-12-19 11:32:14 +00:00
# Check whether STL is libstdc++
check_cxx_source_compiles (
"
#include <vector>
i n t main ( ) {
#if ! defined(__GLIBCXX__) && ! defined(__GLIBCPP__)
t h i s i s n o t l i b s t d c + +
#endif
return ( 0 ) ;
}
"
2015-05-08 19:12:42 +00:00
l y x _ c v _ l i b _ s t d c x x )
# Check whether STL is libstdc++ with C++11 ABI
check_cxx_source_compiles (
"
#include <vector>
i n t main ( ) {
#if ! defined(_GLIBCXX_USE_CXX11_ABI) || ! _GLIBCXX_USE_CXX11_ABI
t h i s i s n o t l i b s t d c + + u s i n g t h e C + + 1 1 A B I
#endif
return ( 0 ) ;
}
"
U S E _ G L I B C X X _ C X X 1 1 _ A B I )
2014-12-19 11:32:14 +00:00
2014-12-21 16:23:56 +00:00
check_cxx_source_compiles (
"
#ifndef __clang__
t h i s i s n o t c l a n g
#endif
i n t main ( ) {
return ( 0 ) ;
}
"
l y x _ c v _ p r o g _ c l a n g )
2016-06-12 17:56:31 +00:00
check_cxx_source_compiles (
"
#include <memory>
u s i n g s t d : : m a k e _ u n i q u e ;
i n t main ( ) {
return ( 0 ) ;
}
"
H A V E _ D E F _ M A K E _ U N I Q U E )
2016-08-07 09:32:53 +00:00
check_cxx_source_compiles (
"
#include <mutex>
s t a t i c s t d : : o n c e _ f l a g f l a g ;
i n t main ( ) {
s t d : : call_once ( flag, []( ) { r e t u r n ; } ) ;
return ( 0 ) ;
}
"
L Y X _ U S E _ S T D _ C A L L _ O N C E )
2018-01-24 15:19:34 +00:00
if ( ENCHANT_FOUND )
set ( CMAKE_REQUIRED_INCLUDES ${ ENCHANT_INCLUDE_DIR } )
set ( CMAKE_REQUIRED_LIBRARIES ${ ENCHANT_LIBRARY } )
# Check, whether enchant is version 2.x at least
check_cxx_source_compiles (
"
#include <enchant++.h>
e n c h a n t : : B r o k e r b r o k e r ;
i n t main ( ) {
return ( 0 ) ;
}
"
H A V E _ E N C H A N T 2 )
if ( HAVE_ENCHANT2 )
message ( STATUS "ENCHANT2 found" )
endif ( )
endif ( )
2014-12-21 16:23:56 +00:00
set ( USE_LLVM_LIBCPP )
2015-05-08 19:12:42 +00:00
set ( STD_STRING_USES_COW )
set ( USE_GLIBCXX_CXX11_ABI )
if ( lyx_cv_lib_stdcxx )
if ( NOT USE_GLIBCXX_CXX11_ABI )
set ( STD_STRING_USES_COW 1 )
endif ( )
else ( )
2014-12-21 16:23:56 +00:00
if ( lyx_cv_prog_clang )
# use libc++ provided by llvm instead of GNU libstdc++
set ( USE_LLVM_LIBCPP 1 )
endif ( )
endif ( )
2014-12-08 16:43:05 +00:00
2016-07-10 17:31:32 +00:00
set ( QPA_XCB )
set ( HAVE_QT5_X11_EXTRAS )
2014-06-12 05:52:45 +00:00
if ( LYX_USE_QT MATCHES "QT5" )
2016-07-10 17:31:32 +00:00
set ( CMAKE_REQUIRED_INCLUDES ${ Qt5Core_INCLUDE_DIRS } )
set ( CMAKE_REQUIRED_FLAGS )
#message(STATUS "Qt5Core_INCLUDE_DIRS = ${Qt5Core_INCLUDE_DIRS}")
2017-02-22 23:18:52 +00:00
check_include_file_cxx ( QtGui/qtgui-config.h HAVE_QTGUI_CONFIG_H )
if ( HAVE_QTGUI_CONFIG_H )
set ( lyx_qt5_config "QtGui/qtgui-config.h" )
else ( )
set ( lyx_qt5_config "QtCore/qconfig.h" )
endif ( )
2018-02-10 10:21:08 +00:00
if ( WIN32 )
set ( QT_USES_X11 CACHE "Win32 compiled without X11" 0 )
# The try_run for minngw would not work here anyway
else ( )
check_cxx_source_runs (
"
#include <${lyx_qt5_config}>
#include <string>
u s i n g n a m e s p a c e s t d ;
s t r i n g a ( QT_QPA_DEFAULT_PLATFORM_NAME ) ;
i n t main ( int argc, char **argv )
{
if ( a.compare(\ "xcb\" ) = = 0 )
return ( 0 ) ;
e l s e
r e t u r n 1 ;
}
"
Q T _ U S E S _ X 1 1 )
if ( QT_USES_X11 )
set ( QPA_XCB ${ QT_USES_X11 } )
endif ( )
endif ( )
2016-07-10 17:31:32 +00:00
2014-06-12 05:52:45 +00:00
if ( Qt5X11Extras_FOUND )
get_target_property ( _x11extra_prop Qt5::X11Extras IMPORTED_CONFIGURATIONS )
get_target_property ( _x11extra_link_libraries Qt5::X11Extras IMPORTED_LOCATION_ ${ _x11extra_prop } )
set ( CMAKE_REQUIRED_LIBRARIES ${ _x11extra_link_libraries } )
set ( CMAKE_REQUIRED_INCLUDES ${ Qt5X11Extras_INCLUDE_DIRS } )
2016-05-30 06:22:15 +00:00
set ( CMAKE_REQUIRED_FLAGS "${Qt5X11Extras_EXECUTABLE_COMPILE_FLAGS} -fPIC -DQT_NO_VERSION_TAGGING" )
#message(STATUS "CMAKE_REQUIRED_LIBRARIES = ${_x11extra_link_libraries}")
#message(STATUS "CMAKE_REQUIRED_INCLUDES = ${Qt5X11Extras_INCLUDE_DIRS}")
#message(STATUS "CMAKE_REQUIRED_FLAGS = ${CMAKE_REQUIRED_FLAGS}")
2014-06-12 05:52:45 +00:00
check_cxx_source_compiles (
"
#include <QtX11Extras/QX11Info>
i n t main ( )
{
b o o l i s X 1 1 = Q X 1 1 I n f o : : isPlatformX11 ( ) ;
}
"
2016-07-10 17:31:32 +00:00
Q T _ H A S _ X 1 1 _ E X T R A S )
set ( HAVE_QT5_X11_EXTRAS ${ QT_HAS_X11_EXTRAS } )
2016-07-11 17:08:11 +00:00
set ( LYX_QT5_X11_EXTRAS_LIBRARY ${ _x11extra_link_libraries } )
2014-06-12 05:52:45 +00:00
endif ( )
2014-12-26 15:53:31 +00:00
if ( Qt5WinExtras_FOUND )
get_target_property ( _winextra_prop Qt5::WinExtras IMPORTED_CONFIGURATIONS )
2015-12-15 12:08:48 +00:00
string ( TOUPPER ${ CMAKE_BUILD_TYPE } BUILD_TYPE )
get_target_property ( _winextra_link_libraries Qt5::WinExtras IMPORTED_LOCATION_ ${ BUILD_TYPE } )
2014-12-26 15:53:31 +00:00
set ( CMAKE_REQUIRED_LIBRARIES ${ _winextra_link_libraries } )
set ( CMAKE_REQUIRED_INCLUDES ${ Qt5WinExtras_INCLUDE_DIRS } )
set ( CMAKE_REQUIRED_FLAGS ${ Qt5WinExtras_EXECUTABLE_COMPILE_FLAGS } )
endif ( )
2014-06-12 05:52:45 +00:00
elseif ( LYX_USE_QT MATCHES "QT4" )
2014-05-25 11:50:18 +00:00
set ( CMAKE_REQUIRED_LIBRARIES ${ QT_QTGUI_LIBRARY } )
set ( CMAKE_REQUIRED_INCLUDES ${ QT_INCLUDES } )
check_cxx_source_compiles (
"
#include <QtGui/QX11Info>
i n t main ( )
{
Q X 1 1 I n f o * q x i = n e w Q X 1 1 I n f o ;
q x i - > ~ QX11Info ( ) ;
}
"
Q T _ U S E S _ X 1 1 )
2014-06-12 05:52:45 +00:00
else ( )
message ( FATAL_ERROR "Check for QT_USES_X11: Not handled LYX_USE_QT (= ${LYX_USE_QT})" )
2014-05-25 11:50:18 +00:00
endif ( )