Skip to content

Commit fd2f5e8

Browse files
committed
[CMake] Correctly set library prefix on Windows
Instead of adding the prefix to the output name, it should be set separately.
1 parent c893075 commit fd2f5e8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

cmake/modules/RootMacros.cmake

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -918,14 +918,10 @@ function(ROOT_LINKER_LIBRARY library)
918918
if(ARG_TEST) # we are building a test, so add EXCLUDE_FROM_ALL
919919
set(_all EXCLUDE_FROM_ALL)
920920
endif()
921-
set(library_name ${library})
922921
if(TARGET ${library})
923922
message(FATAL_ERROR "Target ${library} already exists.")
924923
endif()
925924
if(WIN32 AND ARG_TYPE STREQUAL SHARED AND NOT ARG_DLLEXPORT)
926-
if(MSVC)
927-
set(library_name ${libprefix}${library})
928-
endif()
929925
#---create a shared library with the .def file------------------------
930926
add_library(${library} ${_all} SHARED ${lib_srcs})
931927
set_target_properties(${library} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
@@ -958,7 +954,10 @@ function(ROOT_LINKER_LIBRARY library)
958954
endif()
959955
endif()
960956

961-
set_target_properties(${library} PROPERTIES OUTPUT_NAME ${library_name})
957+
set_target_properties(${library} PROPERTIES
958+
PREFIX ${libprefix}
959+
IMPORT_PREFIX ${libprefix} # affects the .lib import library (MSVC)
960+
)
962961
target_include_directories(${library} INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
963962
# Do not add -Dname_EXPORTS to the command-line when building files in this
964963
# target. Doing so is actively harmful for the modules build because it

0 commit comments

Comments
 (0)