Skip to content

Commit 4fb9b8d

Browse files
fix: windows compile issue
1 parent 825cb97 commit 4fb9b8d

13 files changed

Lines changed: 74 additions & 46 deletions

File tree

base/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ add_subdirectory(device)
2121
# Create the unified shared library
2222
add_library(cfbase SHARED)
2323

24-
# Link static libraries from sub-modules
25-
target_link_libraries(cfbase PUBLIC
24+
# Link static libraries from sub-modules with --whole-archive to ensure
25+
# all symbols (including dllexport) are included in cfbase.dll.
26+
# Without this, the linker skips static lib objects since cfbase has no own sources.
27+
# Force all objects into cfbase.dll (PRIVATE: only affects cfbase's link step)
28+
target_link_libraries(cfbase PRIVATE
29+
-Wl,--whole-archive
2630
cfbase_cpu
2731
cfbase_memory
2832
cfbase_network
2933
cfbase_gpu
3034
cfbase_console
35+
-Wl,--no-whole-archive
3136
)
3237

3338
# Set include directories

base/include/system/network/network.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct IpAddress {
103103
* @since N/A
104104
* @ingroup none
105105
*/
106-
std::string toString() const;
106+
CF_BASE_EXPORT std::string toString() const;
107107
};
108108

109109
/**
@@ -282,7 +282,7 @@ struct InterfaceInfo {
282282
* @since N/A
283283
* @ingroup none
284284
*/
285-
std::optional<IpAddress> firstIPv4() const noexcept;
285+
CF_BASE_EXPORT std::optional<IpAddress> firstIPv4() const noexcept;
286286

287287
/**
288288
* @brief Retrieves the first IPv6 address on this interface.
@@ -293,7 +293,7 @@ struct InterfaceInfo {
293293
* @since N/A
294294
* @ingroup none
295295
*/
296-
std::optional<IpAddress> firstIPv6() const noexcept;
296+
CF_BASE_EXPORT std::optional<IpAddress> firstIPv6() const noexcept;
297297
};
298298

299299
/**
@@ -392,6 +392,6 @@ cf::expected<NetworkInfo, NetworkQueryError> CF_BASE_EXPORT getNetworkInfo() noe
392392
* @since N/A
393393
* @ingroup none
394394
*/
395-
const char* interfaceTypeName(InterfaceType t);
395+
CF_BASE_EXPORT const char* interfaceTypeName(InterfaceType t);
396396

397397
} // namespace cf

desktop/base/logger/include/cflog/cflog.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*/
1414
#pragma once
1515

16-
#include "base/singleton/simple_singleton.hpp"
1716
#include "cflog_export.h"
1817
#include "cflog_level.hpp"
1918
#include <atomic>
@@ -69,10 +68,7 @@ class CFLOG_API Logger {
6968
*
7069
* @return Logger&
7170
*/
72-
static Logger& instance() {
73-
static Logger* inst = new Logger();
74-
return *inst;
75-
}
71+
static Logger& instance();
7672

7773
/**
7874
* @brief Logs a message with the specified level and metadata.

desktop/base/logger/src/logger/cflog.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ namespace cf::log {
88
// Logger Implementation
99
// ============================================================================
1010

11+
Logger& Logger::instance() {
12+
static Logger* inst = new Logger();
13+
return *inst;
14+
}
15+
1116
Logger::Logger() : logger_impl(std::make_shared<LoggerImpl>()) {
1217
// No default sink - user must configure sinks explicitly
1318
}

test/ui/components/CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
# Layer 4: Material Behavior Layer Tests
33
# =============================================================================
44

5+
# Common link libraries for component tests (use cfui shared library)
6+
set(COMPONENT_TEST_LIBS "cfui;Qt6::Widgets;GTest::gtest;GTest::gtest_main")
7+
58
# =============================================================================
69
# state_machine_test
710
# =============================================================================
811
add_gtest_executable(
912
TEST_NAME state_machine_test
1013
SOURCE_FILE state_machine_test.cpp
11-
LINK_LIBRARIES cf_ui_widget_material;cf_ui_application_support;cf_ui_components;cf_ui_core;GTest::gtest;GTest::gtest_main
14+
LINK_LIBRARIES ${COMPONENT_TEST_LIBS}
1215
LABELS "ui;components;layer4;state"
1316
LOG_MODULE ui_components_tests
1417
)
@@ -19,7 +22,7 @@ add_gtest_executable(
1922
add_gtest_executable(
2023
TEST_NAME ripple_helper_test
2124
SOURCE_FILE ripple_helper_test.cpp
22-
LINK_LIBRARIES cf_ui_widget_material;cf_ui_application_support;cf_ui_components;cf_ui_core;GTest::gtest;GTest::gtest_main
25+
LINK_LIBRARIES ${COMPONENT_TEST_LIBS}
2326
LABELS "ui;components;layer4;ripple"
2427
LOG_MODULE ui_components_tests
2528
)
@@ -30,7 +33,7 @@ add_gtest_executable(
3033
add_gtest_executable(
3134
TEST_NAME elevation_controller_test
3235
SOURCE_FILE elevation_controller_test.cpp
33-
LINK_LIBRARIES cf_ui_widget_material;cf_ui_application_support;cf_ui_components;cf_ui_core;GTest::gtest;GTest::gtest_main
36+
LINK_LIBRARIES ${COMPONENT_TEST_LIBS}
3437
LABELS "ui;components;layer4;elevation"
3538
LOG_MODULE ui_components_tests
3639
)
@@ -41,7 +44,7 @@ add_gtest_executable(
4144
add_gtest_executable(
4245
TEST_NAME focus_ring_test
4346
SOURCE_FILE focus_ring_test.cpp
44-
LINK_LIBRARIES cf_ui_widget_material;cf_ui_application_support;cf_ui_components;cf_ui_core;GTest::gtest;GTest::gtest_main
47+
LINK_LIBRARIES ${COMPONENT_TEST_LIBS}
4548
LABELS "ui;components;layer4;focus"
4649
LOG_MODULE ui_components_tests
4750
)
@@ -52,7 +55,7 @@ add_gtest_executable(
5255
add_gtest_executable(
5356
TEST_NAME painter_layer_test
5457
SOURCE_FILE painter_layer_test.cpp
55-
LINK_LIBRARIES cf_ui_widget_material;cf_ui_application_support;cf_ui_components;cf_ui_core;GTest::gtest;GTest::gtest_main
58+
LINK_LIBRARIES ${COMPONENT_TEST_LIBS}
5659
LABELS "ui;components;layer4;painter"
5760
LOG_MODULE ui_components_tests
5861
)

test/ui/widget/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
# =============================================================================
44

55
# Common link libraries for widget tests
6-
# Note: No gtest_main — each test provides its own main() with QGuiApplication
6+
# Note: Use cfui shared library to match __declspec(dllimport) in headers.
7+
# No gtest_main — each test provides its own main() with QGuiApplication
78
set(WIDGET_TEST_LIBS
8-
cf_ui_widget_material;cf_ui_application_support;cf_ui_components;cf_ui_core;Qt6::Gui;Qt6::Widgets;GTest::gtest
9+
cfui;Qt6::Widgets;GTest::gtest
910
)
1011

1112
# =============================================================================

ui/CMakeLists.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ project(UI DESCRIPTION "CFDesktop UI Components" LANGUAGES CXX)
22

33
log_info("UI" "Start UI Components Configurations")
44

5+
# All sources under ui/ are compiled into cfui.dll, so define cfui_EXPORTS
6+
# so that CF_UI_EXPORT expands to __declspec(dllexport) instead of dllimport.
7+
add_compile_definitions(cfui_EXPORTS)
8+
59
# Base Supports the UI Components Needs
610
add_subdirectory(base)
711

@@ -24,21 +28,29 @@ add_subdirectory(models)
2428

2529
add_library(cfui SHARED)
2630

27-
# Link against STATIC libraries from sub-modules
28-
# Order: dependencies first (left), then dependents (right)
29-
# Static libraries are linked left-to-right, so dependents must come after their dependencies
30-
target_link_libraries(cfui PUBLIC
31+
# Force all objects into cfui.dll (PRIVATE: only affects cfui's own link step).
32+
# cfui has no own sources, so the linker would otherwise skip static lib objects.
33+
# Note: cf_ui_widget is an INTERFACE library — use its actual static lib deps instead.
34+
target_link_libraries(cfui PRIVATE
35+
-Wl,--whole-archive
3136
cf_ui_base
3237
cf_ui_core
33-
cf_ui_widget
38+
cf_ui_core_material
39+
cf_ui_widget_material
40+
cf_ui_application_support
3441
cf_ui_components_material
3542
cf_ui_components
43+
-Wl,--no-whole-archive
3644
)
3745

3846
# Set include directories
3947
target_include_directories(cfui PUBLIC
48+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
4049
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
50+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/base>
4151
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/core>
52+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/components>
53+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/components/material>
4254
$<INSTALL_INTERFACE:include>
4355
)
4456

ui/base/color.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#pragma once
16+
#include "export.h"
1617
#include <QColor>
1718
#include <QString>
1819

@@ -41,7 +42,7 @@ namespace cf::ui::base {
4142
* float t = color.tone();
4243
* @endcode
4344
*/
44-
class CFColor {
45+
class CF_UI_EXPORT CFColor {
4546
public:
4647
/**
4748
* @brief Default constructor.

ui/base/color_helper.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414
#pragma once
1515
#include "color.h"
16+
#include "export.h"
1617
#include <QList>
1718

1819
namespace cf::ui::base {
@@ -30,7 +31,7 @@ namespace cf::ui::base {
3031
* @since 0.1
3132
* @ingroup ui
3233
*/
33-
CFColor blend(const CFColor& base, CFColor& overlay, float ratio);
34+
CF_UI_EXPORT CFColor blend(const CFColor& base, CFColor& overlay, float ratio);
3435

3536
/**
3637
* @brief Applies elevation overlay to a surface color.
@@ -45,7 +46,7 @@ CFColor blend(const CFColor& base, CFColor& overlay, float ratio);
4546
* @since 0.1
4647
* @ingroup ui
4748
*/
48-
CFColor elevationOverlay(CFColor& surface, CFColor& primary, int elevation);
49+
CF_UI_EXPORT CFColor elevationOverlay(CFColor& surface, CFColor& primary, int elevation);
4950

5051
/**
5152
* @brief Calculates the contrast ratio between two colors.
@@ -59,7 +60,7 @@ CFColor elevationOverlay(CFColor& surface, CFColor& primary, int elevation);
5960
* @since 0.1
6061
* @ingroup ui
6162
*/
62-
float contrastRatio(CFColor& a, CFColor& b);
63+
CF_UI_EXPORT float contrastRatio(CFColor& a, CFColor& b);
6364

6465
/**
6566
* @brief Generates a tonal palette from a key color.
@@ -72,6 +73,6 @@ float contrastRatio(CFColor& a, CFColor& b);
7273
* @since 0.1
7374
* @ingroup ui
7475
*/
75-
QList<CFColor> tonalPalette(CFColor keyColor);
76+
CF_UI_EXPORT QList<CFColor> tonalPalette(CFColor keyColor);
7677

7778
} // namespace cf::ui::base

ui/base/device_pixel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* @ingroup ui
1313
*/
1414
#pragma once
15+
#include "export.h"
1516
#include <QtTypes>
1617

1718
namespace cf::ui::base {
@@ -32,7 +33,7 @@ namespace device {
3233
*
3334
* @ingroup ui
3435
*/
35-
struct CanvasUnitHelper {
36+
struct CF_UI_EXPORT CanvasUnitHelper {
3637
/**
3738
* @brief Constructs a CanvasUnitHelper with the specified device pixel ratio.
3839
*

0 commit comments

Comments
 (0)