Skip to content

Commit 41d57d0

Browse files
committed
Fix SYSTEMC_UNITY_BUILD for static builds with custom main()
When building SystemC as a static library with SYSTEMC_UNITY_BUILD=ON, linking fails if the user defines their own main() (e.g., in a test) because the internal sc_main.cpp object is included in the unity build and conflicts with the custom main(). This patch excludes sc_main.cpp from unity builds to restore expected behavior for static linking scenarios with external main() definitions. Signed-off-by: Ruben Brandhofer <[email protected]>
1 parent e7d46b0 commit 41d57d0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ function(add_systemc_library libName scBuildDefine)
129129
if(SYSTEMC_UNITY_BUILD)
130130
message(STATUS "Enable SystemC unity build")
131131
set_target_properties(${libName} PROPERTIES UNITY_BUILD ON)
132+
set_source_files_properties(sysc/kernel/sc_main.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
132133
set_source_files_properties(sysc/utils/sc_utils_ids.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
133134
else()
134135
message(STATUS "Disable SystemC unity build")

0 commit comments

Comments
 (0)