Do not crash on SHARED library without language (#13324)

Since commit e1409ac5 (Support building shared libraries or modules
without soname, 2012-04-22) CMake crashes on the code

 add_library(foo SHARED foo.nolang)

because the logic to lookup the language's soname flag was moved from
cmTarget::GetLibraryNames to cmMakefile::GetSONameFlag without its check
for a NULL language.  Restore the check for NULL.

Add RunCMake.Languages test to cover language error cases like this one.
This commit is contained in:
Brad King 2012-06-20 11:04:35 -04:00
parent 8df7aa54f0
commit 56148fd2bc
8 changed files with 16 additions and 2 deletions

View File

@ -2197,8 +2197,12 @@ bool cmMakefile::PlatformIs64Bit() const
const char* cmMakefile::GetSONameFlag(const char* language) const
{
std::string name = "CMAKE_SHARED_LIBRARY_SONAME_";
name += language;
std::string name = "CMAKE_SHARED_LIBRARY_SONAME";
if(language)
{
name += "_";
name += language;
}
name += "_FLAG";
return GetDefinition(name.c_str());
}

View File

@ -45,6 +45,7 @@ macro(add_RunCMake_test test)
)
endmacro()
add_RunCMake_test(Languages)
add_RunCMake_test(ObjectLibrary)
add_RunCMake_test(build_command)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
CMake Error: CMake can not determine linker language for target:NoLang

View File

@ -0,0 +1 @@
add_library(NoLang SHARED foo.nolang)

View File

@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(NoLangSHARED)

View File