#StackBounty: #c++ #c #cmake CMake – Changing shared library link options

Bounty: 200

I want to manipulate the linker call in my linker trampoline python script, but for the life of me I cannot get CMake to respect the CMAKE_CXX_CREATE_SHARED_LIBRARY value. It always uses the CMAKE_CXX_COMPILER for linking. If I switch to an add_executable and instead use CMAKE_CXX_LINK_EXECUTABLE this works perfectly. Is there anyway to convince CMake to respect the setting of CMAKE_CXX_CREATE_SHARED_LIBRARY?

A trivial CMakeLists.txt

cmake_minimum_required( VERSION 3.12 )

project( mylib )

include( CMakePrintSystemInformation )

add_library( mylib SHARED mylib.cpp )

A toolchain excerpt

I’ve tried this in both a toolchain file and an -C pre-cache option.

set( CMAKE_LINKER "/path/to/linker_trampoline.py" )

Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.