Re: CMake + clang failure

2016-06-11 Thread Scott Kostyshak
On Sat, Jun 11, 2016 at 01:07:45PM +0200, Stephan Witt wrote:
> Am 11.06.2016 um 12:28 schrieb Kornel Benko :
> > 
> > Am Samstag, 11. Juni 2016 um 11:57:07, schrieb Georg Baum 
> > 
> >> Kornel Benko wrote:
> >> 
> >>> I have a check for regex, what about the attached?
> >>> 1.) Determine if 'regex-source' compiles in FindCXX11Compiler.cmake
> >>> 2.) Use the value in case of 'clang' in CMakeLists.txt
> >> 
> >> Perfect, thanks a lot!
> > 
> > Some googling helps a lot.
> > 
> >>> Maybe we should use this value unconditionally?
> >> 
> >> This would depend on how exactly the old gcc regex implementation is: If 
> >> it 
> >> is broken at compile time we could use it unconditionally. If it is broken 
> >> only at runtime it would not help. I would play on the safe side here and 
> >> use explicitly our knowledge that it is broken for old gcc.
> >> 
> > 
> > OK. Committed.
> 
> It’s working on Mac again.

Compiling master with clang now works for me on Linux.

Thanks,

Scott

> 
> Stephan


signature.asc
Description: PGP signature


Re: CMake + clang failure

2016-06-11 Thread Stephan Witt
Am 11.06.2016 um 13:33 schrieb Kornel Benko :
> 
> Am Samstag, 11. Juni 2016 um 13:07:45, schrieb Stephan Witt 
>> Am 11.06.2016 um 12:28 schrieb Kornel Benko :
>>> 
>>> Am Samstag, 11. Juni 2016 um 11:57:07, schrieb Georg Baum 
>>> 
 Kornel Benko wrote:
 
> I have a check for regex, what about the attached?
> 1.) Determine if 'regex-source' compiles in FindCXX11Compiler.cmake
> 2.) Use the value in case of 'clang' in CMakeLists.txt
 
 Perfect, thanks a lot!
>>> 
>>> Some googling helps a lot.
>>> 
> Maybe we should use this value unconditionally?
 
 This would depend on how exactly the old gcc regex implementation is: If 
 it 
 is broken at compile time we could use it unconditionally. If it is broken 
 only at runtime it would not help. I would play on the safe side here and 
 use explicitly our knowledge that it is broken for old gcc.
 
>>> 
>>> OK. Committed.
>> 
>> It’s working on Mac again.
>> 
>> Stephan
> 
> Nice. You mean, you have overcome the cmake-rpath problems too?

No, but a working "make all“ obviously is a prerequisite for „make install“ :)

Stephan

Re: CMake + clang failure

2016-06-11 Thread Kornel Benko
Am Samstag, 11. Juni 2016 um 13:07:45, schrieb Stephan Witt 
> Am 11.06.2016 um 12:28 schrieb Kornel Benko :
> > 
> > Am Samstag, 11. Juni 2016 um 11:57:07, schrieb Georg Baum 
> > 
> >> Kornel Benko wrote:
> >> 
> >>> I have a check for regex, what about the attached?
> >>> 1.) Determine if 'regex-source' compiles in FindCXX11Compiler.cmake
> >>> 2.) Use the value in case of 'clang' in CMakeLists.txt
> >> 
> >> Perfect, thanks a lot!
> > 
> > Some googling helps a lot.
> > 
> >>> Maybe we should use this value unconditionally?
> >> 
> >> This would depend on how exactly the old gcc regex implementation is: If 
> >> it 
> >> is broken at compile time we could use it unconditionally. If it is broken 
> >> only at runtime it would not help. I would play on the safe side here and 
> >> use explicitly our knowledge that it is broken for old gcc.
> >> 
> > 
> > OK. Committed.
> 
> It’s working on Mac again.
> 
> Stephan

Nice. You mean, you have overcome the cmake-rpath problems too?

Kornel

signature.asc
Description: This is a digitally signed message part.


Re: CMake + clang failure

2016-06-11 Thread Stephan Witt
Am 11.06.2016 um 12:28 schrieb Kornel Benko :
> 
> Am Samstag, 11. Juni 2016 um 11:57:07, schrieb Georg Baum 
> 
>> Kornel Benko wrote:
>> 
>>> I have a check for regex, what about the attached?
>>> 1.) Determine if 'regex-source' compiles in FindCXX11Compiler.cmake
>>> 2.) Use the value in case of 'clang' in CMakeLists.txt
>> 
>> Perfect, thanks a lot!
> 
> Some googling helps a lot.
> 
>>> Maybe we should use this value unconditionally?
>> 
>> This would depend on how exactly the old gcc regex implementation is: If it 
>> is broken at compile time we could use it unconditionally. If it is broken 
>> only at runtime it would not help. I would play on the safe side here and 
>> use explicitly our knowledge that it is broken for old gcc.
>> 
> 
> OK. Committed.

It’s working on Mac again.

Stephan

Re: CMake + clang failure

2016-06-11 Thread Kornel Benko
Am Samstag, 11. Juni 2016 um 11:57:07, schrieb Georg Baum 

> Kornel Benko wrote:
> 
> > I have a check for regex, what about the attached?
> > 1.) Determine if 'regex-source' compiles in FindCXX11Compiler.cmake
> > 2.) Use the value in case of 'clang' in CMakeLists.txt
> 
> Perfect, thanks a lot!

Some googling helps a lot.

> > Maybe we should use this value unconditionally?
> 
> This would depend on how exactly the old gcc regex implementation is: If it 
> is broken at compile time we could use it unconditionally. If it is broken 
> only at runtime it would not help. I would play on the safe side here and 
> use explicitly our knowledge that it is broken for old gcc.
> 

OK. Committed.

> Georg

Kornel

signature.asc
Description: This is a digitally signed message part.


Re: CMake + clang failure

2016-06-11 Thread Georg Baum
Kornel Benko wrote:

> I have a check for regex, what about the attached?
> 1.) Determine if 'regex-source' compiles in FindCXX11Compiler.cmake
> 2.) Use the value in case of 'clang' in CMakeLists.txt

Perfect, thanks a lot!

> Maybe we should use this value unconditionally?

This would depend on how exactly the old gcc regex implementation is: If it 
is broken at compile time we could use it unconditionally. If it is broken 
only at runtime it would not help. I would play on the safe side here and 
use explicitly our knowledge that it is broken for old gcc.


Georg



Re: CMake + clang failure

2016-06-11 Thread Kornel Benko
Am Samstag, 11. Juni 2016 um 10:36:47, schrieb Georg Baum 

> Kornel Benko wrote:
>
> > OK, but my second question is not answered. To what value  should
> > LYX_USE_STD_REGEX be set?
>
> It should be autodetected. The algorithm of autotools is:
>
> detect presence of . If available and compiler is clang, use
> std::regex.
>
> This is however not 100% correct: If clang is used on linux with the gcc
> stdlib, then a version check would be needed for the gcc stdlib as well,
> since it would use the broken gcc implementation of the lib comes from a gcc
> older than 4.9. This check is currently not implemented. Therefore it was
> good than Jean-Marc introduced the possibility to disable stdregex manually
> at 6f585055d918.
>
>
> Georg

I have a check for regex, what about the attached?
1.) Determine if 'regex-source' compiles in FindCXX11Compiler.cmake
2.) Use the value in case of 'clang' in CMakeLists.txt

Maybe we should use this value unconditionally?

Kornel

signature.asc
Description: This is a digitally signed message part.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fee89e1..1bc690a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -260,17 +260,29 @@ if(NOT CXX11COMPILER_FOUND)
 endif()
 set(LYX_GCC11_MODE)
 if(UNIX OR MINGW)
-	execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
-	message(STATUS "Using GCC version ${GCC_VERSION}")
-	if(GCC_VERSION VERSION_LESS 4.9)
-		if(GCC_VERSION VERSION_LESS 4.3)
-			message(FATAL_ERROR "gcc >= 4.3 is required.")
-		endif()
-		#  in gcc is unusable in versions less than 4.9.0
-		# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
-		set(LYX_USE_STD_REGEX 0)
+	if (CMAKE_CXX_COMPILER_ID MATCHES "^[cC]lang$")
+	  # ignore the GCC_VERSION for clang
+	  # We pretend the compiler version >= 4.9
+	  message(STATUS "Using clang")
+	  # CXX11_STD_REGEX found in FindCXX11Compiler.cmake
+	  if(CXX11_STD_REGEX)
+	set(LYX_USE_STD_REGEX 1)
+	  else()
+	set(LYX_USE_STD_REGEX 0)
+	  endif()
 	else()
-		set(LYX_USE_STD_REGEX 1)
+	  execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
+	  message(STATUS "Using GCC version ${GCC_VERSION}")
+	  if(GCC_VERSION VERSION_LESS 4.9)
+		  if(GCC_VERSION VERSION_LESS 4.3)
+			  message(FATAL_ERROR "gcc >= 4.3 is required.")
+		  endif()
+		  #  in gcc is unusable in versions less than 4.9.0
+		  # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
+		  set(LYX_USE_STD_REGEX 0)
+	  else()
+		  set(LYX_USE_STD_REGEX 1)
+	  endif()
 	endif()
 	set(LYX_GCC11_MODE "${CXX11_FLAG}")
 else()
diff --git a/development/cmake/modules/FindCXX11Compiler.cmake b/development/cmake/modules/FindCXX11Compiler.cmake
index 7d09f8f..2c711c8 100644
--- a/development/cmake/modules/FindCXX11Compiler.cmake
+++ b/development/cmake/modules/FindCXX11Compiler.cmake
@@ -80,6 +80,25 @@ int main() {
 };
 ")
 
+set(REGEX_TEST_SOURCE
+"
+#include 
+#include 
+
+#include 
+
+typedef std::regex_iterator Myiter;
+int main()
+{
+const char *pat = \"axayaz\";
+Myiter::regex_type rx(\"a\");
+Myiter next(pat, pat + strlen(pat), rx);
+Myiter end;
+
+return (0);
+}
+")
+
 # check c compiler
 set(SAFE_CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET})
 set(CMAKE_REQUIRED_QUIET ON)
@@ -93,7 +112,15 @@ FOREACH(FLAG ${CXX11_FLAG_CANDIDATES})
 SET(CXX11_FLAG "${FLAG}")
 message(STATUS "CXX11_FLAG_DETECTED = \"${FLAG}\"")
 set(LYX_USE_CXX11 1)
-BREAK()
+  check_cxx_source_compiles("${REGEX_TEST_SOURCE}" CXX_STD_REGEX_DETECTED)
+  if (CXX_STD_REGEX_DETECTED)
+	message(STATUS "Compiler supports std_regex")
+	set(CXX11_STD_REGEX ON)
+  else()
+	message(STATUS "Compiler does not support std_regex")
+	set(CXX11_STD_REGEX OFF)
+  endif()
+break()
   ENDIF()
 ENDFOREACH()
 set(CMAKE_REQUIRED_QUIET ${SAFE_CMAKE_REQUIRED_QUIET})
@@ -101,4 +128,4 @@ set(CMAKE_REQUIRED_QUIET ${SAFE_CMAKE_REQUIRED_QUIET})
 # handle the standard arguments for find_package
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(CXX11Compiler DEFAULT_MSG CXX11_FLAG)
 
-MARK_AS_ADVANCED(CXX11_FLAG)
+MARK_AS_ADVANCED(CXX11_FLAG CXX11_STD_REGEX)


Re: CMake + clang failure

2016-06-11 Thread Georg Baum
Kornel Benko wrote:

> OK, but my second question is not answered. To what value  should
> LYX_USE_STD_REGEX be set?

It should be autodetected. The algorithm of autotools is:

detect presence of . If available and compiler is clang, use 
std::regex.

This is however not 100% correct: If clang is used on linux with the gcc 
stdlib, then a version check would be needed for the gcc stdlib as well, 
since it would use the broken gcc implementation of the lib comes from a gcc 
older than 4.9. This check is currently not implemented. Therefore it was 
good than Jean-Marc introduced the possibility to disable stdregex manually 
at 6f585055d918.


Georg



Re: CMake + clang failure

2016-06-11 Thread Kornel Benko
Am Samstag, 11. Juni 2016 um 09:58:59, schrieb Georg Baum 

> Kornel Benko wrote:
> 
> > Should we really ignore output of '${CMAKE_CXX_COMPILER} -dumpversion'?
> 
> In case of clang yes, since clang outputs an arbitrary number which has 
> nothing to do with the clang version. Sooner or later we will need clang 
> version tests as well (and then we will need to figure out how to get the 
> real clang version), but currently all clang versions meet our requirements.
> 
> > Some questions:
> > 1.) What if the compiler is even older?
> > or
> > 2.) Should we in this case assume GCC_VERSION >= 4.9?
> > 
> > One possible fix is appended.
> 
> I would prefer not to set GCC_VERSION at all when clang is used (this is 
> what autotools do). It is more clean, since clang is not gcc. For gcc the 
> current version check should be fine.
> 

OK, but my second question is not answered. To what value  should 
LYX_USE_STD_REGEX be set?

> Georg

Kornel

signature.asc
Description: This is a digitally signed message part.


Re: CMake + clang failure

2016-06-11 Thread Georg Baum
Kornel Benko wrote:

> Should we really ignore output of '${CMAKE_CXX_COMPILER} -dumpversion'?

In case of clang yes, since clang outputs an arbitrary number which has 
nothing to do with the clang version. Sooner or later we will need clang 
version tests as well (and then we will need to figure out how to get the 
real clang version), but currently all clang versions meet our requirements.

> Some questions:
> 1.) What if the compiler is even older?
> or
> 2.) Should we in this case assume GCC_VERSION >= 4.9?
> 
> One possible fix is appended.

I would prefer not to set GCC_VERSION at all when clang is used (this is 
what autotools do). It is more clean, since clang is not gcc. For gcc the 
current version check should be fine.


Georg



Re: CMake + clang failure

2016-06-11 Thread Kornel Benko
Am Samstag, 11. Juni 2016 um 08:25:58, schrieb Georg Baum 

> Guillaume Munch wrote:
>
> > Le 11/06/2016 03:00, Scott Kostyshak a écrit :
> >> -- Using GCC version 4.2.1
> >> CMake Error at CMakeLists.txt:267 (message):
> >>gcc >= 4.3 is required.
> >
> >  From INSTALL:
> >
> >First of all, you will need a recent C++ compiler, where recent means
> >that the compilers are close to C++11 standard conforming like gcc (at
> >least 4.3) or clang.
> >
> > I do not know clang, but I am surprised, gcc 4.2 is very old. I
> > requested to drop gcc 4.6 in a recent message.
>
> From config/lyxinclude.m4:
>
> dnl clang++ pretends to be g++ 4.2.1; this is not useful
>
> This is the reason why the version test now fails.
>
> I forgot to test cmake+clang when requiring a C++11 compiler.
> clang+autotools work fine. This is beyond my cmake knowledge. Kornel, do you
> have an idea how to fix this? autotools detect clang and then ignore the gcc
> version, see LYX_PROG_CLANG and the line I quoted (both from
> config/lyxinclude.m4).
>
>
> Georg

Should we really ignore output of '${CMAKE_CXX_COMPILER} -dumpversion'?

Some questions:
1.) What if the compiler is even older?
or
2.) Should we in this case assume GCC_VERSION >= 4.9?

One possible fix is appended.

Kornel

signature.asc
Description: This is a digitally signed message part.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fee89e1..95a89d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -261,16 +261,23 @@ endif()
 set(LYX_GCC11_MODE)
 if(UNIX OR MINGW)
 	execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
-	message(STATUS "Using GCC version ${GCC_VERSION}")
-	if(GCC_VERSION VERSION_LESS 4.9)
-		if(GCC_VERSION VERSION_LESS 4.3)
-			message(FATAL_ERROR "gcc >= 4.3 is required.")
-		endif()
-		#  in gcc is unusable in versions less than 4.9.0
-		# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
-		set(LYX_USE_STD_REGEX 0)
+	if (CMAKE_CXX_COMPILER_ID MATCHES "^[cC]lang$")
+	  # ignore the GCC_VERSION for clang
+	  # We pretend the compiler version >= 4.9
+	  message(STATUS "Using clang version ${GCC_VERSION}")
+	  set(LYX_USE_STD_REGEX 1)
 	else()
-		set(LYX_USE_STD_REGEX 1)
+	  message(STATUS "Using GCC version ${GCC_VERSION}")
+	  if(GCC_VERSION VERSION_LESS 4.9)
+		  if(GCC_VERSION VERSION_LESS 4.3)
+			  message(FATAL_ERROR "gcc >= 4.3 is required.")
+		  endif()
+		  #  in gcc is unusable in versions less than 4.9.0
+		  # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
+		  set(LYX_USE_STD_REGEX 0)
+	  else()
+		  set(LYX_USE_STD_REGEX 1)
+	  endif()
 	endif()
 	set(LYX_GCC11_MODE "${CXX11_FLAG}")
 else()


Re: CMake + clang failure

2016-06-10 Thread Georg Baum
Guillaume Munch wrote:

> Le 11/06/2016 03:00, Scott Kostyshak a écrit :
>> -- Using GCC version 4.2.1
>> CMake Error at CMakeLists.txt:267 (message):
>>gcc >= 4.3 is required.
> 
>  From INSTALL:
> 
>First of all, you will need a recent C++ compiler, where recent means
>that the compilers are close to C++11 standard conforming like gcc (at
>least 4.3) or clang.
> 
> I do not know clang, but I am surprised, gcc 4.2 is very old. I
> requested to drop gcc 4.6 in a recent message.

>From config/lyxinclude.m4:

dnl clang++ pretends to be g++ 4.2.1; this is not useful

This is the reason why the version test now fails.

I forgot to test cmake+clang when requiring a C++11 compiler. 
clang+autotools work fine. This is beyond my cmake knowledge. Kornel, do you 
have an idea how to fix this? autotools detect clang and then ignore the gcc 
version, see LYX_PROG_CLANG and the line I quoted (both from 
config/lyxinclude.m4).


Georg



Re: CMake + clang failure

2016-06-10 Thread Guillaume Munch

Le 11/06/2016 03:00, Scott Kostyshak a écrit :

-- Using GCC version 4.2.1
CMake Error at CMakeLists.txt:267 (message):
   gcc >= 4.3 is required.


From INSTALL:

  First of all, you will need a recent C++ compiler, where recent means
  that the compilers are close to C++11 standard conforming like gcc (at
  least 4.3) or clang.

I do not know clang, but I am surprised, gcc 4.2 is very old. I
requested to drop gcc 4.6 in a recent message.



Re: CMake + clang failure

2016-06-10 Thread Stephan Witt
Am 11.06.2016 um 04:00 schrieb Scott Kostyshak :
> 
> $ export CC=/usr/bin/clang
> $ export CXX=/usr/bin/clang++
> $ cmake ../repo
> -- TOP_SRC_DIR = /home/scott/lyxbuilds/master/repo
> -- 
> -- Building out-of-source
> -- The C compiler identification is Clang 3.6.0
> -- The CXX compiler identification is Clang 3.6.0
> -- Check for working C compiler: /usr/bin/clang
> -- Check for working C compiler: /usr/bin/clang -- works
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Check for working CXX compiler: /usr/bin/clang++
> -- Check for working CXX compiler: /usr/bin/clang++ -- works
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> -- 
> -- Performing Test CXX11_FLAG_DETECTED
> -- Performing Test CXX11_FLAG_DETECTED - Success
> -- CXX11_FLAG_DETECTED = "--std=c++11 -Wno-deprecated-register"
> -- Found CXX11Compiler: --std=c++11 -Wno-deprecated-register  
> -- Using GCC version 4.2.1
> CMake Error at CMakeLists.txt:267 (message):
>  gcc >= 4.3 is required.
> 
> 
> -- Configuring incomplete, errors occurred!
> See also "/home/scott/lyxbuilds/master/CMakeBuild/CMakeFiles/CMakeOutput.log".
> $ 
> 
> Scott

The same here on Mac:

Stephan

Using SDK 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-- TOP_SRC_DIR = /Users/stephan/git/lyx
-- 
-- Building out-of-source
-- The C compiler identification is AppleClang 7.3.0.7030029
-- The CXX compiler identification is AppleClang 7.3.0.7030029
-- Check for working C compiler using: Xcode
-- Check for working C compiler using: Xcode -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler using: Xcode
-- Check for working CXX compiler using: Xcode -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 
-- CXX11_FLAG_DETECTED = "--std=c++11 -Wno-deprecated-register"
-- Found CXX11Compiler: --std=c++11 -Wno-deprecated-register  
-- Using GCC version 4.2.1
CMake Error at CMakeLists.txt:267 (message):
  gcc >= 4.3 is required.


-- Configuring incomplete, errors occurred!
See also 
"/Users/stephan/git/lyx-build/cmake/2.3.0dev/CMakeFiles/CMakeOutput.log".



CMake + clang failure

2016-06-10 Thread Scott Kostyshak
$ export CC=/usr/bin/clang
$ export CXX=/usr/bin/clang++
$ cmake ../repo
-- TOP_SRC_DIR = /home/scott/lyxbuilds/master/repo
-- 
-- Building out-of-source
-- The C compiler identification is Clang 3.6.0
-- The CXX compiler identification is Clang 3.6.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- 
-- Performing Test CXX11_FLAG_DETECTED
-- Performing Test CXX11_FLAG_DETECTED - Success
-- CXX11_FLAG_DETECTED = "--std=c++11 -Wno-deprecated-register"
-- Found CXX11Compiler: --std=c++11 -Wno-deprecated-register  
-- Using GCC version 4.2.1
CMake Error at CMakeLists.txt:267 (message):
  gcc >= 4.3 is required.


-- Configuring incomplete, errors occurred!
See also "/home/scott/lyxbuilds/master/CMakeBuild/CMakeFiles/CMakeOutput.log".
$ 

Scott


signature.asc
Description: PGP signature