MantisBT - CMake
View Issue Details
0014602CMakeCMakepublic2013-11-27 13:442014-10-06 10:32
Aleix Pol 
 
normalminoralways
closedno change required 
CMake 2.8.12 
 
0014602: Make it possible to disable SONAME generation for libraries
I'm working on a Toolchain file for Android. The soname doesn't work there, so I want to be able to disable it without having to modify the source code of the library to adapt by removing the set_properties that set the SONAME.
I tried with the NO_SONAME and IMPORTED_NO_SONAME properties and setting CMAKE_SHARED_LIBRARY_SONAME_C_FLAG to "", but it didn't seem to help.
No tags attached.
Issue History
2013-11-27 13:44Aleix PolNew Issue
2013-12-02 09:29Brad KingNote Added: 0034664
2013-12-02 09:34Aleix PolNote Added: 0034665
2013-12-02 09:56Brad KingNote Added: 0034667
2013-12-02 09:56Brad KingSticky IssueNo => Yes
2013-12-02 09:56Brad KingSticky IssueYes => No
2014-02-24 19:20Aleix PolNote Added: 0035178
2014-02-24 19:21Stephen KellyNote Added: 0035179
2014-02-25 07:58Brad KingNote Added: 0035181
2014-02-25 15:54Aleix PolNote Added: 0035197
2014-02-25 16:05Brad KingNote Added: 0035198
2014-02-25 16:06Brad KingNote Added: 0035199
2014-02-25 19:58Aleix PolNote Added: 0035200
2014-02-26 07:59Brad KingNote Added: 0035202
2014-02-26 07:59Brad KingStatusnew => resolved
2014-02-26 07:59Brad KingResolutionopen => no change required
2014-10-06 10:32Robert MaynardNote Added: 0036914
2014-10-06 10:32Robert MaynardStatusresolved => closed

Notes
(0034664)
Brad King   
2013-12-02 09:29   
Setting NO_SONAME is expected to work:

http://www.cmake.org/cmake/help/v2.8.12/cmake.html#prop_tgt:NO_SONAME [^]
http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmTarget.cxx;hb=v2.8.12.1#l4500 [^]

Can you post a minimal example where it fails?
(0034665)
Aleix Pol   
2013-12-02 09:34   
NO_SONAME is a per-target property, I need to set it to the whole project.

That's why I said I needed to do it from a Toolchain file.

Is it possible to set a property for all targets?
(0034667)
Brad King   
2013-12-02 09:56   
The toolchain file and platform information modules need to be configured to set CMAKE_SHARED_LIBRARY_SONAME_C_FLAG to empty if the platform does not support it. The value is set by Modules/Platform/*.cmake files based on known capabilities of each platform. Therefore you must not be configuring CMake to load the proper platform information files.
(0035178)
Aleix Pol   
2014-02-24 19:20   
Why does it make a difference when is it initialized?

Should I patch cmake to be able to disable so-names then?
(0035179)
Stephen Kelly   
2014-02-24 19:21   
> NO_SONAME is a per-target property, I need to set it to the whole project.

But you said it doesn't work, even as a per-target property.
(0035181)
Brad King   
2014-02-25 07:58   
Re 0014602:0035178: The CMAKE_SHARED_LIBRARY_SONAME_C_FLAG is not a cache entry, but a normal CMake language variable. The Modules/Platform/*.cmake files set the value and will override anything that you try to set in the toolchain file because they are loaded later. The problem is that your toolchain file is telling CMake to target a particular platform, and CMake knows that platform supports soname with a certain flag. If that is not true then you are telling CMake to target the wrong platform.
(0035197)
Aleix Pol   
2014-02-25 15:54   
Noted, we understand the problem. I'm trying to find a solution.

It's android, so it's using Linux as a base. The platform file is processed after the Toolchain file is executed, so I have no possibility to change. Should I create another Platform file for Android that overrides this, then?

For reference, see [1] (take it as a proof of concept).

[1] http://quickgit.kde.org/?p=scratch%2Fapol%2Fkalgebraandroid.git&a=blob&h=d32657afec060afe980f44f57cea6b86774c4d43&f=AndroidToolchain.cmake&o=plain [^]
(0035198)
Brad King   
2014-02-25 16:05   
Add a Platform/Android.cmake file under a directory in your CMAKE_MODULE_PATH and set the CMAKE_SYSTEM_NAME to Android. In Android.cmake place the content

 include(Platform/Linux)
 set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "")

and any other overrides you want.
(0035199)
Brad King   
2014-02-25 16:06   
Re 0014602:0035198: Actually, even simpler is to just add a Platform/Linux.cmake file to your CMAKE_MODULE_PATH that does

 include(${CMAKE_ROOT}/Modules/Platform/Linux.cmake)
 set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "")

and any other overrides you want. Then you do not need to change CMAKE_SYSTEM_NAME.
(0035200)
Aleix Pol   
2014-02-25 19:58   
That worked great, I didn't know I could have a different Platform/ directory.

Please, consider the bug fixed (I don't think I can close it).

I'll leave it like that for the moment. If you think the Toolchain file is worth contributing upstream, please tell me. I know there are things to polish still, but I think it could be a first step.
(0035202)
Brad King   
2014-02-26 07:59   
Great, thanks for reporting back.
(0036914)
Robert Maynard   
2014-10-06 10:32   
Closing resolved issues that have not been updated in more than 4 months.