From 24b55bfe11db52b37795b241272b0a1511e12bd5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Aug 2006 09:26:36 -0400 Subject: [PATCH] BUG: Make sure sources with unknown extensions are not compiled by VS. --- Source/cmLocalVisualStudioGenerator.cxx | 16 +++++++++++++--- Tests/Complex/Executable/A.txt | 1 + Tests/Complex/Executable/CMakeLists.txt | 2 +- Tests/ComplexOneConfig/Executable/A.txt | 1 + Tests/ComplexOneConfig/Executable/CMakeLists.txt | 2 +- Tests/ComplexRelativePaths/Executable/A.txt | 1 + .../Executable/CMakeLists.txt | 2 +- 7 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 Tests/Complex/Executable/A.txt create mode 100644 Tests/ComplexOneConfig/Executable/A.txt create mode 100644 Tests/ComplexRelativePaths/Executable/A.txt diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 5ff096671..16164d103 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -33,9 +33,19 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator() //---------------------------------------------------------------------------- bool cmLocalVisualStudioGenerator::SourceFileCompiles(const cmSourceFile* sf) { - return (!sf->GetCustomCommand() && - !sf->GetPropertyAsBool("HEADER_FILE_ONLY") && - !sf->GetPropertyAsBool("EXTERNAL_OBJECT")); + // Identify the language of the source file. + if(const char* lang = this->GetSourceFileLanguage(*sf)) + { + // Check whether this source will actually be compiled. + return (!sf->GetCustomCommand() && + !sf->GetPropertyAsBool("HEADER_FILE_ONLY") && + !sf->GetPropertyAsBool("EXTERNAL_OBJECT")); + } + else + { + // Unknown source file language. Assume it will not be compiled. + return false; + } } //---------------------------------------------------------------------------- diff --git a/Tests/Complex/Executable/A.txt b/Tests/Complex/Executable/A.txt new file mode 100644 index 000000000..8ee9462be --- /dev/null +++ b/Tests/Complex/Executable/A.txt @@ -0,0 +1 @@ +This file should not be compiled! diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt index 71fde7b6d..12b14368a 100644 --- a/Tests/Complex/Executable/CMakeLists.txt +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -19,7 +19,7 @@ ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) LINK_LIBRARIES(${COMPLEX_LIBS}) -ADD_EXECUTABLE(A A.cxx A.hh A.h) +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) ADD_EXECUTABLE(complex complex testcflags.c ) # Sub1/NameConflictTest.c Sub2/NameConflictTest.c) ADD_EXECUTABLE(complex.file complex.file.cxx) diff --git a/Tests/ComplexOneConfig/Executable/A.txt b/Tests/ComplexOneConfig/Executable/A.txt new file mode 100644 index 000000000..8ee9462be --- /dev/null +++ b/Tests/ComplexOneConfig/Executable/A.txt @@ -0,0 +1 @@ +This file should not be compiled! diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt index 71fde7b6d..12b14368a 100644 --- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -19,7 +19,7 @@ ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) LINK_LIBRARIES(${COMPLEX_LIBS}) -ADD_EXECUTABLE(A A.cxx A.hh A.h) +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) ADD_EXECUTABLE(complex complex testcflags.c ) # Sub1/NameConflictTest.c Sub2/NameConflictTest.c) ADD_EXECUTABLE(complex.file complex.file.cxx) diff --git a/Tests/ComplexRelativePaths/Executable/A.txt b/Tests/ComplexRelativePaths/Executable/A.txt new file mode 100644 index 000000000..8ee9462be --- /dev/null +++ b/Tests/ComplexRelativePaths/Executable/A.txt @@ -0,0 +1 @@ +This file should not be compiled! diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt index 71fde7b6d..12b14368a 100644 --- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt @@ -19,7 +19,7 @@ ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) LINK_LIBRARIES(${COMPLEX_LIBS}) -ADD_EXECUTABLE(A A.cxx A.hh A.h) +ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt) ADD_EXECUTABLE(complex complex testcflags.c ) # Sub1/NameConflictTest.c Sub2/NameConflictTest.c) ADD_EXECUTABLE(complex.file complex.file.cxx)