Skip to content

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Nov 9, 2025

If CMake reports the target platform not supporting shared libs, turn
BUILD_SHARED_LIBS off by default. CMake 3.30+ fails with an error
when trying to create a SHARED target for such platforms. Earlier
versions used a workaround that may or may not have worked in practice.

Ref: https://cmake.org/cmake/help/v3.30/policy/CMP0164.html

Seen this with a build setting -DCMAKE_SYSTEM_NAME=Generic, e.g.
AmigaOS.

Note this may introduce incompatibility for "Generic" targets, which
support shared libs. If that's the case, set BUILD_SHARED_LIBS=ON
manually.

Also drop AmigaOS-specific logic handled automatically after this patch.

Ref: https://cmake.org/cmake/help/v3.7/command/get_property.html
Ref: https://cmake.org/cmake/help/v3.7/prop_gbl/TARGET_SUPPORTS_SHARED_LIBS.html


CMake built-in targets potentially affected as of today:

Modules/Compiler/CrayPrgEnv.cmake:    set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
Modules/Compiler/Tasking.cmake:set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
Modules/Platform/ADSP.cmake:set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
Modules/Platform/ARTOS.cmake:set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
Modules/Platform/BlueGeneL.cmake:set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
Modules/Platform/Catamount.cmake:set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
Modules/Platform/CrayLinuxEnvironment.cmake:  set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
Modules/Platform/Euros.cmake:set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
Modules/Platform/Generic.cmake:set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
Modules/Platform/eCos.cmake:set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)

If CMake reports the target platform not supporting shared libs, turn
`BUILD_SHARED_LIBS` off by default. CMake 3.30+ fails with an error
when trying to create a SHARED target for such such platforms. Earlier
versions used a workaround that may or may not have worked in practice.

Ref: https://cmake.org/cmake/help/latest/policy/CMP0164.html

Seen this with a build setting `-DCMAKE_SYSTEM_NAME=Generic`, e.g.
AmigaOS.

Note this may introduce incompatibility for "Generic" targets, which
support shared libs. If that's the case, set `BUILD_SHARED_LIBS=ON`
manually.

Also drop AmigaOS-specific logic that's now handled automatically.
@vszakats vszakats changed the title cmake: handle targets not supporting shared libs cmake: adjust defaults for target platforms not supporting shared libs Nov 9, 2025
@vszakats vszakats closed this in 49ef2f8 Nov 9, 2025
@vszakats vszakats deleted the cm-no-shared branch November 9, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant