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:
parent
8df7aa54f0
commit
56148fd2bc
|
@ -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)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
|
@ -0,0 +1 @@
|
|||
1
|
|
@ -0,0 +1 @@
|
|||
CMake Error: CMake can not determine linker language for target:NoLang
|
|
@ -0,0 +1 @@
|
|||
add_library(NoLang SHARED foo.nolang)
|
|
@ -0,0 +1,3 @@
|
|||
include(RunCMake)
|
||||
|
||||
run_cmake(NoLangSHARED)
|
Loading…
Reference in New Issue