diff --git a/build-support/cmake-format-modules.yaml b/build-support/cmake-format-modules.yaml index 8e31ee133..61c5d6be7 100644 --- a/build-support/cmake-format-modules.yaml +++ b/build-support/cmake-format-modules.yaml @@ -12,7 +12,7 @@ additional_commands: DEFINITIONS : '*' build_lib: - flags: [IGNORE_PCH] + flags: [IGNORE_PCH, GENERATE_EXPORT_HEADER] kwargs: LIBNAME : '1' SOURCE_FILES : '*' diff --git a/build-support/cmake-format.yaml b/build-support/cmake-format.yaml index afc2664d2..76f9e004b 100644 --- a/build-support/cmake-format.yaml +++ b/build-support/cmake-format.yaml @@ -12,7 +12,7 @@ additional_commands: DEFINITIONS : '*' build_lib: - flags: [IGNORE_PCH] + flags: [IGNORE_PCH, GENERATE_EXPORT_HEADER] kwargs: LIBNAME : '1' SOURCE_FILES : '*' diff --git a/build-support/custom-modules/ns3-module-macros.cmake b/build-support/custom-modules/ns3-module-macros.cmake index eb2f716a9..e99f7d95e 100644 --- a/build-support/custom-modules/ns3-module-macros.cmake +++ b/build-support/custom-modules/ns3-module-macros.cmake @@ -194,6 +194,13 @@ function(build_lib) set(export_dest ${CMAKE_HEADER_OUTPUT_DIRECTORY}/${BLIB_LIBNAME}-export.h) file(COPY_FILE ${export_file} ${export_dest}) install(FILES ${export_file} DESTINATION include/ns3 COMPONENT Headers) + + # In case building on Visual Studio + if(${MSVC}) + target_compile_definitions( + ${BLIB_LIBNAME} PRIVATE ${BLIB_LIBNAME}_EXPORTS + ) + endif() endif() # Reuse PCH @@ -361,7 +368,7 @@ endfunction() function(build_lib_export_definitions_as_interface_definitions libname) get_target_property(target_definitions ${libname} COMPILE_DEFINITIONS) - if(${target_definitions} STREQUAL "target_definitions-NOTFOUND") + if("${target_definitions}" STREQUAL "target_definitions-NOTFOUND") set(target_definitions) endif() get_directory_property(dir_definitions COMPILE_DEFINITIONS)