8000 Further modernize CMake build. · log4cplus/log4cplus@f50489b · GitHub
[go: up one dir, main page]

Skip to content

Commit f50489b

Browse files
committed
Further modernize CMake build.
1 parent c60b532 commit f50489b

File tree

5 files changed

+24
-26
lines changed

5 files changed

+24
-26
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ option(LOG4CPLUS_BUILD_LOGGINGSERVER "Build the logging server." ON)
4242

4343
option(LOG4CPLUS_REQUIRE_EXPLICIT_INITIALIZATION "Require explicit initialization (see log4cplus::Initializer)" OFF)
4444
if (LOG4CPLUS_REQUIRE_EXPLICIT_INITIALIZATION)
45-
add_definitions (-DLOG4CPLUS_REQUIRE_EXPLICIT_INITIALIZATION=1)
45+
add_compile_definitions (LOG4CPLUS_REQUIRE_EXPLICIT_INITIALIZATION=1)
4646
endif(LOG4CPLUS_REQUIRE_EXPLICIT_INITI 8000 ALIZATION)
4747

4848
if(NOT LOG4CPLUS_SINGLE_THREADED)
@@ -79,7 +79,7 @@ option(LOG4CPLUS_SINGLE_THREADED
7979
"Define if you want to build single-threaded version of the library."
8080
OFF)
8181
if (LOG4CPLUS_SINGLE_THREADED)
82-
add_definitions (-DLOG4CPLUS_SINGLE_THREADED=1)
82+
add_compile_definitions (LOG4CPLUS_SINGLE_THREADED=1)
8383
endif (LOG4CPLUS_SINGLE_THREADED)
8484

8585
option (LOG4CPLUS_QT4 "Build with Qt4DebugAppender" OFF)
@@ -101,9 +101,9 @@ endif()
101101
option(WITH_UNIT_TESTS "Enable unit tests" ON)
102102
if (WITH_UNIT_TESTS)
103103
set (LOG4CPLUS_WITH_UNIT_TESTS 1)
104-
add_definitions (-DCATCH_CONFIG_PREFIX_ALL=1)
104+
add_compile_definitions (CATCH_CONFIG_PREFIX_ALL=1)
105105
if (WIN32)
106-
add_definitions (-DLOG4CPLUS_WITH_UNIT_TESTS=1)
106+
add_compile_definitions (LOG4CPLUS_WITH_UNIT_TESTS=1)
107107
endif (WIN32)
108108
endif (WITH_UNIT_TESTS)
109109

qt4debugappender/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
set (qt4debugappender_sources
22
qt4debugappender.cxx)
33

4-
if (${BUILD_SHARED_LIBS})
5-
add_definitions (-D${log4cplus}_EXPORTS)
6-
endif ()
7-
84
find_package (Qt4 REQUIRED)
95
include (${QT_USE_FILE})
106

@@ -15,15 +11,18 @@ if (UNICODE)
1511
target_compile_definitions (${qt4debugappender} PUBLIC _UNICODE)
1612
add_definitions (-UMBCS -U_MBCS)
1713
endif (UNICODE)
14+
if (${BUILD_SHARED_LIBS})
15+
target_compile_definitions (${qt4debugappender} PRIVATE ${log4cplus}_EXPORTS)
16+
endif ()
1817
target_link_libraries (${qt4debugappender}
1918
${log4cplus}
2019
${QT_LIBRARIES}
2120
${CMAKE_THREAD_LIBS_INIT})
2221

2322
set_target_properties (${qt4debugappender} PROPERTIES
2423
VERSION "${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}"
25-
SOVERSION "${log4cplus_soversion}"
26-
COMPILE_FLAGS "-DINSIDE_LOG4CPLUS_QT4DEBUGAPPENDER")
24+
SOVERSION "${log4cplus_soversion}")
25+
target_compile_definitions (${qt4debugappender} PRIVATE INSIDE_LOG4CPLUS_QT4DEBUGAPPENDER)
2726

2827
if (WIN32)
2928
set_target_properties (${qt4debugappender} PROPERTIES

qt5debugappender/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
set (qt5debugappender_sources
22
qt5debugappender.cxx)
33

4-
if (${BUILD_SHARED_LIBS})
5-
add_definitions (-D${log4cplus}_EXPORTS)
6-
endif ()
7-
84
find_package (Qt5Core REQUIRED)
95
#include (${QT_USE_FILE})
106

@@ -15,15 +11,18 @@ if (UNICODE)
1511
target_compile_definitions (${qt5debugappender} PUBLIC _UNICODE)
1612
add_definitions (-UMBCS -U_MBCS)
1713
endif (UNICODE)
14+
if (${BUILD_SHARED_LIBS})
15+
target_compile_definitions (${qt5debugappender} PRIVATE ${log4cplus}_EXPORTS)
16+
endif ()
1817
target_link_libraries (${qt5debugappender}
1918
${log4cplus}
2019
${Qt5Widgets_LIBRARIES}
2120
${CMAKE_THREAD_LIBS_INIT})
2221

2322
set_target_properties (${qt5debugappender} PROPERTIES
2423
VERSION "${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}"
25-
SOVERSION "${log4cplus_soversion}"
26-
COMPILE_FLAGS "-DINSIDE_LOG4CPLUS_QT5DEBUGAPPENDER")
24+
SOVERSION "${log4cplus_soversion}")
25+
target_compile_definitions (${qt5debugappender} PRIVATE INSIDE_LOG4CPLUS_QT5DEBUGAPPENDER)
2726

2827
qt5_use_modules(${qt5debugappender} Core)
2928

src/CMakeLists.txt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ elseif (WIN32)
6161
win32consoleappender.cxx
6262
win32debugappender.cxx)
6363

64-
#add_definitions (-DLOG4CPLUS_STATIC)
64+
#add_compile_definitions (LOG4CPLUS_STATIC)
6565
#set (log4cplus_postfix "${log4cplus_postfix}S")
6666
endif ()
6767

6868
# Define _GNU_SOURCE so that functions like `pipe2()` are visible.
69-
add_definitions (-D_GNU_SOURCE=1)
69+
add_compile_definitions (_GNU_SOURCE=1)
7070
if (WIN32)
71-
add_definitions (-DMINGW_HAS_SECURE_API=1)
72-
add_definitions (-D_WIN32_WINNT=${_WIN32_WINNT})
71+
add_compile_definitions (MINGW_HAS_SECURE_API=1)
72+
add_compile_definitions (_WIN32_WINNT=${_WIN32_WINNT})
7373

7474
if (BUILD_SHARED_LIBS)
7575
set(log4cplus_build_shared 1)
@@ -111,13 +111,12 @@ target_link_libraries (${log4cplus} ${log4cplus_LIBS})
111111

112112
if (ANDROID)
113113
# Android does not seem to have SO version support.
114-
set_target_properties (${log4cplus} PROPERTIES
115-
COMPILE_FLAGS "-DINSIDE_LOG4CPLUS")
114+
target_compile_definitions (${log4cplus} PRIVATE INSIDE_LOG4CPLUS)
116115
else ()
117116
set_target_properties (${log4cplus} PROPERTIES
118117
VERSION "${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}"
119-
SOVERSION "${log4cplus_soversion}"
120-
COMPILE_FLAGS "-DINSIDE_LOG4CPLUS")
118+
SOVERSION "${log4cplus_soversion}")
119+
target_compile_definitions (${log4cplus} PRIVATE INSIDE_LOG4CPLUS)
121120
endif ()
122121

123122
if (MINGW AND LOG4CPLUS_MINGW_STATIC_RUNTIME)

tests/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
if (UNICODE)
2-
add_definitions (-DUNICODE -D_UNICODE -UMBCS -U_MBCS)
2+
add_compile_definitions (UNICODE _UNICODE)
3+
add_definitions (-UMBCS -U_MBCS)
34
endif (UNICODE)
45

56
if (${BUILD_SHARED_LIBS})
6-
add_definitions (-Dlog4cplus_EXPORTS)
7+
add_compile_definitions (log4cplus_EXPORTS)
78
endif ()
89

910
# A function to set up a test, since it's the same for each one. Note:

0 commit comments

Comments
 (0)
0