Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-10 Thread Georg Baum
Kornel Benko wrote:

> I am a bit lost, since the small snippet below does not compile on MSVC
> (for unknown reason)
> 
> 
> template 
> struct check
> {
> static_assert(sizeof(int) <= sizeof(T), "not big enough");
> };
> 
> typedef check right_angle_brackets;
> 
> class TestDeleted
> {
> public:
> TestDeleted() = delete;
> };
> 
> 
> int a;
> decltype(a) b;
> 
> typedef check check_type;
> check_type c;
> check_type&& cr = static_cast(c);
> 
> auto d = a;
> 
> int main() {
>   return 0;
> };
> ==

It compiles with this MSVC online compiler: http://webcompiler.cloudapp.net/ 
According to https://msdn.microsoft.com/en-us/library/hh567368.aspx#featurelist 
it should also compile with MSVC 2013. 
Earlier versions do not work because of TestDeleted.

Uwe, can you please apply the patch from Kornel in the first message in this 
thread, delete CMakeCache.txt, try to build and then send me  
CMakeFiles/CMakeError.log? It is too big for the list. This file will tell 
us what goes wrong with the test.

> If it compiles (with any needed compiler flags), then the last patch I
> sent (in the starting mail on this thread) should be similar.
> 
> Sources changed slightly in the meantime, so the patch may not apply
> cleanly. My latest guess was the flag "/Ze" to enable MSVC extensions, but
> I got no response ...

Sorry, I overlooked that. /Ze is for Microsoft extensions, this is not 
needed.


Georg



Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-10 Thread Peter Kümmel

On 10.12.2015 22:48, Kornel Benko wrote:

Am Donnerstag, 10. Dezember 2015 um 21:12:36, schrieb Georg Baum 


Kornel Benko wrote:


I am a bit lost, since the small snippet below does not compile on MSVC
(for unknown reason)


template 
struct check
{
 static_assert(sizeof(int) <= sizeof(T), "not big enough");
};

typedef check right_angle_brackets;

class TestDeleted
{
public:
 TestDeleted() = delete;
};


int a;
decltype(a) b;

typedef check check_type;
check_type c;
check_type&& cr = static_cast(c);

auto d = a;

int main() {
   return 0;
};
==


It compiles with this MSVC online compiler: http://webcompiler.cloudapp.net/
According to https://msdn.microsoft.com/en-us/library/hh567368.aspx#featurelist 
it should also compile with MSVC 2013.
Earlier versions do not work because of TestDeleted.

Uwe, can you please apply the patch from Kornel in the first message in this
thread, delete CMakeCache.txt, try to build and then send me
CMakeFiles/CMakeError.log? It is too big for the list. This file will tell
us what goes wrong with the test.


Maybe also use '--debug-output' as an extra cmake parameter. Than also the file 
CMakeFiles/CMakeOutput.log may be of interest.
I'd like to have both files too.


If it compiles (with any needed compiler flags), then the last patch I
sent (in the starting mail on this thread) should be similar.

Sources changed slightly in the meantime, so the patch may not apply
cleanly. My latest guess was the flag "/Ze" to enable MSVC extensions, but
I got no response ...


Sorry, I overlooked that. /Ze is for Microsoft extensions, this is not
needed.



OK.


Georg


Kornel



Isn't this too much trouble? msvc2013 and msvc2015 have C++11 enabled by 
default.
Not much to do in the cmake files, and whan something has to be changed just use
cmake variables MSVC2012/MSVC2014. Or have I missed something?

Peter


Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-10 Thread Georg Baum
Uwe Stöhr wrote:

> So with a clean git tree one only had to apply the attached patch to get
> cxx11 for MSVC but compiling leads to these 2 errors:
> 
>D:\LyXGit\Master\src\frontends\qt4\GuiView.cpp(3357): error C3848:
> expression having type 'const
> 
std::_Bind &,bool)const,lyx::Buffer::ExportStatus,lyx::Buffer,const std::string
> &,bool>,lyx::Buffer *&,std::_Ph<1> &,bool>' would lose some
> const-volatile qualifiers in order to call 'lyx::Buffer::ExportStatus
> 
std::_Bind const,lyx::Buffer::ExportStatus,lyx::Buffer,const std::string
> &,bool>,lyx::Buffer *&,std::_Ph<1> &,bool>::operator () std::string&>(conststd::string &)'
> [D:\LyXGit\Master\compile-2013\src\frontends\qt4\frontend_qt.vcxproj]
> 
>C:\MSVC2013\VC\include\functional(1241): error C2100: illegal
> indirection (D:\LyXGit\Master\src\insets\InsetText.cpp)
> [D:\LyXGit\Master\compile-2013\src\insets\insets.vcxproj]

Unfortunately I do not understand either of the error messages. Nevertheless 
I would like to fix at least the compiler detection (see other mail), since 
that all the investigation work is not lost, and if somebody tries to 
continue the work he does not need to solve all problems again.


Georg



Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-10 Thread Kornel Benko
Am Donnerstag, 10. Dezember 2015 um 21:12:36, schrieb Georg Baum 

> Kornel Benko wrote:
> 
> > I am a bit lost, since the small snippet below does not compile on MSVC
> > (for unknown reason)
> > 
> > 
> > template 
> > struct check
> > {
> > static_assert(sizeof(int) <= sizeof(T), "not big enough");
> > };
> > 
> > typedef check right_angle_brackets;
> > 
> > class TestDeleted
> > {
> > public:
> > TestDeleted() = delete;
> > };
> > 
> > 
> > int a;
> > decltype(a) b;
> > 
> > typedef check check_type;
> > check_type c;
> > check_type&& cr = static_cast(c);
> > 
> > auto d = a;
> > 
> > int main() {
> >   return 0;
> > };
> > ==
> 
> It compiles with this MSVC online compiler: http://webcompiler.cloudapp.net/ 
> According to 
> https://msdn.microsoft.com/en-us/library/hh567368.aspx#featurelist it should 
> also compile with MSVC 2013. 
> Earlier versions do not work because of TestDeleted.
> 
> Uwe, can you please apply the patch from Kornel in the first message in this 
> thread, delete CMakeCache.txt, try to build and then send me  
> CMakeFiles/CMakeError.log? It is too big for the list. This file will tell 
> us what goes wrong with the test.

Maybe also use '--debug-output' as an extra cmake parameter. Than also the file 
CMakeFiles/CMakeOutput.log may be of interest.
I'd like to have both files too.

> > If it compiles (with any needed compiler flags), then the last patch I
> > sent (in the starting mail on this thread) should be similar.
> > 
> > Sources changed slightly in the meantime, so the patch may not apply
> > cleanly. My latest guess was the flag "/Ze" to enable MSVC extensions, but
> > I got no response ...
> 
> Sorry, I overlooked that. /Ze is for Microsoft extensions, this is not 
> needed.
> 

OK.

> Georg

Kornel

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


Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-10 Thread Kornel Benko
Am Donnerstag, 10. Dezember 2015 um 23:39:17, schrieb Peter Kümmel 

> On 10.12.2015 22:48, Kornel Benko wrote:
> > Am Donnerstag, 10. Dezember 2015 um 21:12:36, schrieb Georg Baum 
> > 
> >> Kornel Benko wrote:
> >>
> >>> I am a bit lost, since the small snippet below does not compile on MSVC
> >>> (for unknown reason)
> >>>
> >>> 
> >>> template 
> >>> struct check
> >>> {
> >>>  static_assert(sizeof(int) <= sizeof(T), "not big enough");
> >>> };
> >>>
> >>> typedef check right_angle_brackets;
> >>>
> >>> class TestDeleted
> >>> {
> >>> public:
> >>>  TestDeleted() = delete;
> >>> };
> >>>
> >>>
> >>> int a;
> >>> decltype(a) b;
> >>>
> >>> typedef check check_type;
> >>> check_type c;
> >>> check_type&& cr = static_cast(c);
> >>>
> >>> auto d = a;
> >>>
> >>> int main() {
> >>>return 0;
> >>> };
> >>> ==
> >>
> >> It compiles with this MSVC online compiler: 
> >> http://webcompiler.cloudapp.net/
> >> According to 
> >> https://msdn.microsoft.com/en-us/library/hh567368.aspx#featurelist it 
> >> should also compile with MSVC 2013.
> >> Earlier versions do not work because of TestDeleted.
> >>
> >> Uwe, can you please apply the patch from Kornel in the first message in 
> >> this
> >> thread, delete CMakeCache.txt, try to build and then send me
> >> CMakeFiles/CMakeError.log? It is too big for the list. This file will tell
> >> us what goes wrong with the test.
> >
> > Maybe also use '--debug-output' as an extra cmake parameter. Than also the 
> > file CMakeFiles/CMakeOutput.log may be of interest.
> > I'd like to have both files too.
> >
> >>> If it compiles (with any needed compiler flags), then the last patch I
> >>> sent (in the starting mail on this thread) should be similar.
> >>>
> >>> Sources changed slightly in the meantime, so the patch may not apply
> >>> cleanly. My latest guess was the flag "/Ze" to enable MSVC extensions, but
> >>> I got no response ...
> >>
> >> Sorry, I overlooked that. /Ze is for Microsoft extensions, this is not
> >> needed.
> >>
> >
> > OK.
> >
> >> Georg
> >
> > Kornel
> >
> 
> Isn't this too much trouble? msvc2013 and msvc2015 have C++11 enabled by 
> default.
> Not much to do in the cmake files, and whan something has to be changed just 
> use
> cmake variables MSVC2012/MSVC2014. Or have I missed something?

I think yes. I'd like use some built-in tests to check for compiler features.
That way we may have less conditional code in cmake scripts.

And to know, why a compilation fails, is of some value too.

> Peter

Kornel

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


Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-09 Thread Kornel Benko
Am Mittwoch, 9. Dezember 2015 um 22:28:04, schrieb Georg Baum 

> Uwe Stöhr wrote:
> 
> > I tried this but this doesn't make a difference. Also if I comment out
> > the cxx11 part in regex.h the compilation fails as soon as I set
> > 
> > set(LYX_USE_CXX11 1)
> > 
> > I then get many of these:
> > 
> > D:\LyXGit\Master\src\tex2lyx\table.cpp(284): error C3861: 'min':
> > identifier not found
> 
> This is probably a side effect of less unneeded includes in C++11 mode. 
> std::min is declared in , but table.cpp does not include that 
> header. This is wrong, if it uses std::min then it needs to include 
> 
> 
> Does the error go away if you add the line
> 
> #inlude 
> 
> to table.cpp? If yes, then please do so for all files that complain about 
> std::min and std::max. You have my +1 for this in advance, since these files 
> did only complain by chance previously ( was included indirectly 
> by some other header).
> 
> > So i am relatively sure that we just need to allow std_regex for MSVC
> > while cxx11 is kept disabled for MSVC.
> 
> That does not make sense. std::regex is not part of C++98, it is only part 
> of C++11.
> 
> Unfortunately I lost a bit track of the latest state of the patches. Kornel, 
> how would the final version look like (assuming that the errors above can be 
> fxied, and that we do not want to enable C++11 by default, but let the user 
> choose by adding -DLYX_USE_CXX11=ON to the cmake command line?
> 

I am a bit lost, since the small snippet below does not compile on MSVC (for 
unknown reason)


template 
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};

typedef check right_angle_brackets;

class TestDeleted
{
public:
TestDeleted() = delete;
};


int a;
decltype(a) b;

typedef check check_type;
check_type c;
check_type&& cr = static_cast(c);

auto d = a;

int main() {
  return 0;
};
==

> Georg

If it compiles (with any needed compiler flags), then the last patch I sent (in 
the starting mail on this thread)
should be similar.

Sources changed slightly in the meantime, so the patch may not apply cleanly.
My latest guess was the flag "/Ze" to enable MSVC extensions, but I got no 
response ...

Kornel

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


Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-09 Thread Georg Baum
Uwe Stöhr wrote:

> I tried this but this doesn't make a difference. Also if I comment out
> the cxx11 part in regex.h the compilation fails as soon as I set
> 
> set(LYX_USE_CXX11 1)
> 
> I then get many of these:
> 
> D:\LyXGit\Master\src\tex2lyx\table.cpp(284): error C3861: 'min':
> identifier not found

This is probably a side effect of less unneeded includes in C++11 mode. 
std::min is declared in , but table.cpp does not include that 
header. This is wrong, if it uses std::min then it needs to include 


Does the error go away if you add the line

#inlude 

to table.cpp? If yes, then please do so for all files that complain about 
std::min and std::max. You have my +1 for this in advance, since these files 
did only complain by chance previously ( was included indirectly 
by some other header).

> So i am relatively sure that we just need to allow std_regex for MSVC
> while cxx11 is kept disabled for MSVC.

That does not make sense. std::regex is not part of C++98, it is only part 
of C++11.

Unfortunately I lost a bit track of the latest state of the patches. Kornel, 
how would the final version look like (assuming that the errors above can be 
fxied, and that we do not want to enable C++11 by default, but let the user 
choose by adding -DLYX_USE_CXX11=ON to the cmake command line?


Georg



Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-09 Thread Uwe Stöhr

Am 09.12.2015 um 22:28 schrieb Georg Baum:


D:\LyXGit\Master\src\tex2lyx\table.cpp(284): error C3861: 'min':
identifier not found


This is probably a side effect of less unneeded includes in C++11 mode.
std::min is declared in , but table.cpp does not include that
header. This is wrong, if it uses std::min then it needs to include


Does the error go away if you add the line

#inlude 

to table.cpp?


Yes.

If yes, then please do so for all files that complain about

std::min and std::max. You have my +1 for this in advance, since these files
did only complain by chance previously ( was included indirectly
by some other header).


Done:
www.lyx.org/trac/changeset/219b5645/lyxgit

For InsetCommandParams.cpp I had to include functional because "not1" 
and 'mem_fun_ref' were not found.


So with a clean git tree one only had to apply the attached patch to get 
cxx11 for MSVC but compiling leads to these 2 errors:


  D:\LyXGit\Master\src\frontends\qt4\GuiView.cpp(3357): error C3848: 
expression having type 'const 
std::_Bind,lyx::Buffer *&,std::_Ph<1> &,bool>' would lose some 
const-volatile qualifiers in order to call 'lyx::Buffer::ExportStatus 
std::_Bind,lyx::Buffer *&,std::_Ph<1> &,bool>::operator ()std::string&>(conststd::string &)' 
[D:\LyXGit\Master\compile-2013\src\frontends\qt4\frontend_qt.vcxproj]


  C:\MSVC2013\VC\include\functional(1241): error C2100: illegal 
indirection (D:\LyXGit\Master\src\insets\InsetText.cpp) 
[D:\LyXGit\Master\compile-2013\src\insets\insets.vcxproj]


If we can fix these we have it!

many thanks and best regards
Uwe
diff --git 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\CMa4F79.tmp\\CMakeLists-d9c5483-left.txt"
 "b/D:\\LyXGit\\Master\\CMakeLists.txt"
index 7f1c86a..2a3804b 100644
--- 
"a/C:\\Users\\Usti\\AppData\\Local\\Temp\\TortoiseGit\\CMa4F79.tmp\\CMakeLists-d9c5483-left.txt"
+++ "b/D:\\LyXGit\\Master\\CMakeLists.txt"
@@ -272,9 +272,14 @@ if(UNIX OR MINGW)
endif()
 else()
set(LYX_USE_STD_REGEX 0)
-#  if(MSVC10)
-#  set(LYX_USE_STD_REGEX 1) #TODO should we use it in ECMAScript 
mode?
-#  endif()
+   if (MSVC)
+   if(MSVC_VERSION GREATER 1799)
+   # Microsoft Visual Studio 2013 and newer, e.g. MSVC12 and MSVC14
+   set(LYX_USE_STD_REGEX 1)
+   set(LYX_USE_CXX11 1)
+   set(CXX11_FLAG)
+   endif()
+   endif()
 endif()
 
 


Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-08 Thread Uwe Stöhr

Am 08.12.2015 um 23:55 schrieb Kornel Benko:


Can you set in development/cmake/modules/FindCXX11Compiler.cmake:93

set(FLAG)

instead of
set(FLAG "")


I tried this but this doesn't make a difference. Also if I comment out 
the cxx11 part in regex.h the compilation fails as soon as I set


set(LYX_USE_CXX11 1)

I then get many of these:

D:\LyXGit\Master\src\tex2lyx\table.cpp(284): error C3861: 'min': 
identifier not found


So i am relatively sure that we just need to allow std_regex for MSVC 
while cxx11 is kept disabled for MSVC.


regards Uwe


Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-08 Thread Kornel Benko
Am Dienstag, 8. Dezember 2015 um 23:55:02, schrieb Kornel Benko 
> Am Dienstag, 8. Dezember 2015 um 23:10:21, schrieb Uwe Stöhr 
> 
> > Am 08.12.2015 um 08:51 schrieb Kornel Benko:
> > 
> > > I cannot test, since I don't have MSVC.
> > > In _my_ implementation of cmake modules (cmake 3.4) the MSVC_VERSION is 
> > > defined for MSVC.
> > 
> > Applying this patch breaks the compilation. I get the error
> > 
> > FATAL_ERROR "A C++11 compatible compiler is required."
> > 
> > So find_package(CXX11Compiler) fails.
> > 
> > regards Uwe
> 
> Can you set in development/cmake/modules/FindCXX11Compiler.cmake:93
> 
>   set(FLAG)
> 
> instead of
>   set(FLAG "")
> 
> ?
> 
> Sorry, if this does also not work
> 

Alternatively maybe it helps if set to "/Ze". According to 
https://msdn.microsoft.com/en-us/library/9s7c9wdw.aspx
it enables language extensions.

Kornel

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


Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-08 Thread Kornel Benko
Am Dienstag, 8. Dezember 2015 um 23:10:21, schrieb Uwe Stöhr 
> Am 08.12.2015 um 08:51 schrieb Kornel Benko:
> 
> > I cannot test, since I don't have MSVC.
> > In _my_ implementation of cmake modules (cmake 3.4) the MSVC_VERSION is 
> > defined for MSVC.
> 
> Applying this patch breaks the compilation. I get the error
> 
> FATAL_ERROR "A C++11 compatible compiler is required."
> 
> So find_package(CXX11Compiler) fails.
> 
> regards Uwe

Can you set in development/cmake/modules/FindCXX11Compiler.cmake:93

set(FLAG)

instead of
set(FLAG "")

?

Sorry, if this does also not work

Kornel





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


Re: use FindCXX11Compiler.cmake also for MSVC

2015-12-08 Thread Uwe Stöhr

Am 08.12.2015 um 08:51 schrieb Kornel Benko:


I cannot test, since I don't have MSVC.
In _my_ implementation of cmake modules (cmake 3.4) the MSVC_VERSION is defined 
for MSVC.


Applying this patch breaks the compilation. I get the error

FATAL_ERROR "A C++11 compatible compiler is required."

So find_package(CXX11Compiler) fails.

regards Uwe


use FindCXX11Compiler.cmake also for MSVC

2015-12-07 Thread Kornel Benko
Looking into cmake internal handling of MSVC, maybe this patch should
1.) Unify use of find_package(CXX11Compiler)
2.) Allow using C++11 features for MSVC
3.) using std_regex for MSVC

I cannot test, since I don't have MSVC.
In _my_ implementation of cmake modules (cmake 3.4) the MSVC_VERSION is defined 
for MSVC.

Kornel


signature.asc
Description: This is a digitally signed message part.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5840ad0..d0061c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -260,21 +260,26 @@ if(UNIX OR MINGW)
 			set(LYX_USE_STD_REGEX 1)
 		endif()
 	endif()
-	if (LYX_ENABLE_CXX11)
-		find_package(CXX11Compiler)
-		if(NOT CXX11COMPILER_FOUND)
-			message(FATAL_ERROR "A C++11 compatible compiler is required.")
-		endif()
-		set(LYX_GCC11_MODE "${CXX11_FLAG}")
-	endif()
 else()
 	set(LYX_USE_STD_REGEX 0)
-#	if(MSVC10)
-#		set(LYX_USE_STD_REGEX 1) #TODO should we use it in ECMAScript mode?
-#	endif()
+if (LYX_ENABLE_CXX11)
+  if(MSVC)
+	if(MSVC_VERSION GREATER 1599)
+  # MSVC10 and newer
+	  set(LYX_USE_STD_REGEX 1)
+	endif()
+  endif()
+endif()
+endif()
+
+if (LYX_ENABLE_CXX11)
+  find_package(CXX11Compiler)
+  if(NOT CXX11COMPILER_FOUND)
+message(FATAL_ERROR "A C++11 compatible compiler is required.")
+  endif()
+  set(LYX_GCC11_MODE "${CXX11_FLAG}")
 endif()
 
-
 set(VERSION_INFO "CMake Build")
 
 # Try to get some informations from configure.ac
diff --git a/development/cmake/modules/FindCXX11Compiler.cmake b/development/cmake/modules/FindCXX11Compiler.cmake
index 7d09f8f..822c074 100644
--- a/development/cmake/modules/FindCXX11Compiler.cmake
+++ b/development/cmake/modules/FindCXX11Compiler.cmake
@@ -34,7 +34,12 @@
 INCLUDE(CheckCXXSourceCompiles)
 INCLUDE(FindPackageHandleStandardArgs)
 
-if (CMAKE_CXX_COMPILER_ID MATCHES "^[cC]lang$")
+if (MSVC)
+  if(MSVC_VERSION GREATER 1799)
+# Microsoft Visual Studio 2013 and newer, e.g. MSVC12 and MSVC14
+set(CXX11_FLAG_CANDIDATES "empty")
+  endif()
+elsif (CMAKE_CXX_COMPILER_ID MATCHES "^[cC]lang$")
   set(CXX11_FLAG_CANDIDATES "--std=c++11 -Wno-deprecated-register")
 else()
   if (CYGWIN)
@@ -83,7 +88,12 @@ int main() {
 # check c compiler
 set(SAFE_CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET})
 set(CMAKE_REQUIRED_QUIET ON)
-FOREACH(FLAG ${CXX11_FLAG_CANDIDATES})
+FOREACH(FLAG1 ${CXX11_FLAG_CANDIDATES})
+  if(FLAG1 STREQUAL "empty")
+set(FLAG "")
+  else()
+set(FLAG ${FLAG1})
+  endif()
   SET(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
   SET(CMAKE_REQUIRED_FLAGS "${FLAG}")
   UNSET(CXX11_FLAG_DETECTED CACHE)