From ced61f5722d65525fd4b8dbf96d5ea8f254099c2 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 2 Sep 2010 11:56:40 -0400 Subject: [PATCH 1/4] Let CMake recognize .CPP .CXX and .C++ as c++ files. --- Modules/CMakeCXXCompiler.cmake.in | 4 ++-- Tests/CxxOnly/CMakeLists.txt | 2 +- Tests/CxxOnly/cxxonly.cxx | 4 ++++ Tests/CxxOnly/test.C++ | 1 + Tests/CxxOnly/test.CPP | 1 + Tests/CxxOnly/test.CXX | 1 + 6 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 Tests/CxxOnly/test.C++ create mode 100644 Tests/CxxOnly/test.CPP create mode 100644 Tests/CxxOnly/test.CXX diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index b264da1c9..e1b25d222 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -21,8 +21,8 @@ IF(CMAKE_COMPILER_IS_MINGW) SET(MINGW 1) ENDIF(CMAKE_COMPILER_IS_MINGW) SET(CMAKE_CXX_COMPILER_ID_RUN 1) -SET(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;H;o;O;obj;OBJ;def;DEF;rc;RC) -SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm) +SET(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) +SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;C++;CC;CPP;CXX) SET(CMAKE_CXX_LINKER_PREFERENCE 30) SET(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) diff --git a/Tests/CxxOnly/CMakeLists.txt b/Tests/CxxOnly/CMakeLists.txt index bfc827116..8418ad994 100644 --- a/Tests/CxxOnly/CMakeLists.txt +++ b/Tests/CxxOnly/CMakeLists.txt @@ -2,7 +2,7 @@ project (CxxOnly CXX) set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") -add_library(testcxx1 STATIC libcxx1.cxx) +add_library(testcxx1 STATIC libcxx1.cxx test.CPP test.CXX test.C++) add_library(testcxx2 SHARED libcxx2.cxx) add_executable (CxxOnly cxxonly.cxx) target_link_libraries(CxxOnly testcxx1 testcxx2) diff --git a/Tests/CxxOnly/cxxonly.cxx b/Tests/CxxOnly/cxxonly.cxx index 99ccf3b61..2996e65c8 100644 --- a/Tests/CxxOnly/cxxonly.cxx +++ b/Tests/CxxOnly/cxxonly.cxx @@ -1,10 +1,14 @@ #include "libcxx1.h" #include "libcxx2.h" +extern int testCPP; +extern int testCXX; +extern int testCplusplus; #include int main () { + testCPP = testCXX= testCplusplus = 1; if ( LibCxx1Class::Method() != 2.0 ) { printf("Problem with libcxx1\n"); diff --git a/Tests/CxxOnly/test.C++ b/Tests/CxxOnly/test.C++ new file mode 100644 index 000000000..6049ef12d --- /dev/null +++ b/Tests/CxxOnly/test.C++ @@ -0,0 +1 @@ +int testCplusplus; diff --git a/Tests/CxxOnly/test.CPP b/Tests/CxxOnly/test.CPP new file mode 100644 index 000000000..8a3cde262 --- /dev/null +++ b/Tests/CxxOnly/test.CPP @@ -0,0 +1 @@ +int testCPP; diff --git a/Tests/CxxOnly/test.CXX b/Tests/CxxOnly/test.CXX new file mode 100644 index 000000000..c05f7881a --- /dev/null +++ b/Tests/CxxOnly/test.CXX @@ -0,0 +1 @@ +int testCXX; From d26cd46989b4e1170cbebc97ae3b6b30395158db Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 2 Sep 2010 18:02:57 -0400 Subject: [PATCH 2/4] Only use .CPP .CXX and .C++ do not work by default with g+++. --- Modules/CMakeCXXCompiler.cmake.in | 2 +- Tests/CxxOnly/CMakeLists.txt | 2 +- Tests/CxxOnly/cxxonly.cxx | 4 +--- Tests/CxxOnly/test.C++ | 1 - Tests/CxxOnly/test.CXX | 1 - 5 files changed, 3 insertions(+), 7 deletions(-) delete mode 100644 Tests/CxxOnly/test.C++ delete mode 100644 Tests/CxxOnly/test.CXX diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index e1b25d222..d7ae8d994 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -22,7 +22,7 @@ IF(CMAKE_COMPILER_IS_MINGW) ENDIF(CMAKE_COMPILER_IS_MINGW) SET(CMAKE_CXX_COMPILER_ID_RUN 1) SET(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) -SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;C++;CC;CPP;CXX) +SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP) SET(CMAKE_CXX_LINKER_PREFERENCE 30) SET(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) diff --git a/Tests/CxxOnly/CMakeLists.txt b/Tests/CxxOnly/CMakeLists.txt index 8418ad994..8258eb427 100644 --- a/Tests/CxxOnly/CMakeLists.txt +++ b/Tests/CxxOnly/CMakeLists.txt @@ -2,7 +2,7 @@ project (CxxOnly CXX) set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") -add_library(testcxx1 STATIC libcxx1.cxx test.CPP test.CXX test.C++) +add_library(testcxx1 STATIC libcxx1.cxx test.CPP) add_library(testcxx2 SHARED libcxx2.cxx) add_executable (CxxOnly cxxonly.cxx) target_link_libraries(CxxOnly testcxx1 testcxx2) diff --git a/Tests/CxxOnly/cxxonly.cxx b/Tests/CxxOnly/cxxonly.cxx index 2996e65c8..bd4fd5914 100644 --- a/Tests/CxxOnly/cxxonly.cxx +++ b/Tests/CxxOnly/cxxonly.cxx @@ -1,14 +1,12 @@ #include "libcxx1.h" #include "libcxx2.h" extern int testCPP; -extern int testCXX; -extern int testCplusplus; #include int main () { - testCPP = testCXX= testCplusplus = 1; + testCPP = 1; if ( LibCxx1Class::Method() != 2.0 ) { printf("Problem with libcxx1\n"); diff --git a/Tests/CxxOnly/test.C++ b/Tests/CxxOnly/test.C++ deleted file mode 100644 index 6049ef12d..000000000 --- a/Tests/CxxOnly/test.C++ +++ /dev/null @@ -1 +0,0 @@ -int testCplusplus; diff --git a/Tests/CxxOnly/test.CXX b/Tests/CxxOnly/test.CXX deleted file mode 100644 index c05f7881a..000000000 --- a/Tests/CxxOnly/test.CXX +++ /dev/null @@ -1 +0,0 @@ -int testCXX; From ba0a8905395ec7e616bbedee33a83fcf15a86910 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Mon, 6 Sep 2010 12:43:57 -0400 Subject: [PATCH 3/4] Only test for .CPP on Microsoft compilers which will handle .CPP as c++. --- Tests/CxxOnly/CMakeLists.txt | 5 ++++- Tests/CxxOnly/cxxonly.cxx | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Tests/CxxOnly/CMakeLists.txt b/Tests/CxxOnly/CMakeLists.txt index 8258eb427..4654f44ec 100644 --- a/Tests/CxxOnly/CMakeLists.txt +++ b/Tests/CxxOnly/CMakeLists.txt @@ -2,7 +2,10 @@ project (CxxOnly CXX) set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") -add_library(testcxx1 STATIC libcxx1.cxx test.CPP) +if(MSVC) + set(EXTRA_SRCS test.CPP) +endif() +add_library(testcxx1 STATIC libcxx1.cxx ${EXTRA_SRCS}) add_library(testcxx2 SHARED libcxx2.cxx) add_executable (CxxOnly cxxonly.cxx) target_link_libraries(CxxOnly testcxx1 testcxx2) diff --git a/Tests/CxxOnly/cxxonly.cxx b/Tests/CxxOnly/cxxonly.cxx index bd4fd5914..9cf6f2d29 100644 --- a/Tests/CxxOnly/cxxonly.cxx +++ b/Tests/CxxOnly/cxxonly.cxx @@ -1,12 +1,16 @@ #include "libcxx1.h" #include "libcxx2.h" +#ifdef _MSC_VER extern int testCPP; +#endif #include int main () { +#ifdef _MSC_VER testCPP = 1; +#endif if ( LibCxx1Class::Method() != 2.0 ) { printf("Problem with libcxx1\n"); From 7944e4e0ac37cb1423da2de7a203557b77372aac Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 7 Sep 2010 09:14:57 -0400 Subject: [PATCH 4/4] Allow testing of .CPP on WIN32 as it is a case insensitive OS and should work. --- Tests/CxxOnly/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/CxxOnly/CMakeLists.txt b/Tests/CxxOnly/CMakeLists.txt index 4654f44ec..d621499cc 100644 --- a/Tests/CxxOnly/CMakeLists.txt +++ b/Tests/CxxOnly/CMakeLists.txt @@ -2,7 +2,7 @@ project (CxxOnly CXX) set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") -if(MSVC) +if(WIN32) set(EXTRA_SRCS test.CPP) endif() add_library(testcxx1 STATIC libcxx1.cxx ${EXTRA_SRCS})