Commit 56148fd2 authored by Brad King's avatar Brad King

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.
parent 8df7aa54
......@@ -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());
}
......
......@@ -45,6 +45,7 @@ macro(add_RunCMake_test test)
)
endmacro()
add_RunCMake_test(Languages)
add_RunCMake_test(ObjectLibrary)
add_RunCMake_test(build_command)
......
cmake_minimum_required(VERSION 2.8)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
CMake Error: CMake can not determine linker language for target:NoLang
add_library(NoLang SHARED foo.nolang)
include(RunCMake)
run_cmake(NoLangSHARED)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment