mirror of
https://github.com/curl/curl.git
synced 2025-09-04 19:35:00 +03:00
build: tidy up compiler definition for tests
- tests: merge cmake commands. - tests: use `target_compile_definitions()`. - tests/server: use generator expression for platform-specific macro. - tests/unit: sync `Makefile.am` comment with cmake. - tests/unit: merge two `AM_CPPFLAGS` lines to keep synced with cmake. - tests: move macro definitions to `first.h` headers from build level. `CURL_NO_OLDIES`, `CURL_DISABLE_DEPRECATION`, `WITHOUT_LIBCURL`, `CURL_STATICLIB` (for servers). To share more logic. Pass `CURL_STATICLIB` in server on all platforms for simplicity. (On non-Windows, it's a no-op. It's already done like this with curlu and libcurltool.) Also for lib: - lib: merge commands. - lib: sync macro order with tests (also in `Makefile.am`). Closes #17768
This commit is contained in:
parent
58b9c6134b
commit
2c90c3aac0
|
@ -24,8 +24,7 @@
|
||||||
|
|
||||||
set(LIBCURL_OUTPUT_NAME "${LIB_NAME}" CACHE STRING "Basename of the curl library")
|
set(LIBCURL_OUTPUT_NAME "${LIB_NAME}" CACHE STRING "Basename of the curl library")
|
||||||
|
|
||||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "BUILDING_LIBCURL")
|
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${CURL_DEBUG_MACROS} "BUILDING_LIBCURL")
|
||||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}")
|
|
||||||
|
|
||||||
configure_file("curl_config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/curl_config.h")
|
configure_file("curl_config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/curl_config.h")
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \
|
||||||
# Prevent LIBS from being used for all link targets
|
# Prevent LIBS from being used for all link targets
|
||||||
LIBS = $(BLANK_AT_MAKETIME)
|
LIBS = $(BLANK_AT_MAKETIME)
|
||||||
|
|
||||||
AM_CPPFLAGS += -DBUILDING_LIBCURL
|
|
||||||
AM_LDFLAGS =
|
AM_LDFLAGS =
|
||||||
AM_CFLAGS =
|
AM_CFLAGS =
|
||||||
if DEBUGBUILD
|
if DEBUGBUILD
|
||||||
|
@ -75,6 +74,7 @@ endif
|
||||||
if CURLDEBUG
|
if CURLDEBUG
|
||||||
AM_CPPFLAGS += -DCURLDEBUG
|
AM_CPPFLAGS += -DCURLDEBUG
|
||||||
endif
|
endif
|
||||||
|
AM_CPPFLAGS += -DBUILDING_LIBCURL
|
||||||
|
|
||||||
if DOING_NATIVE_WINDOWS
|
if DOING_NATIVE_WINDOWS
|
||||||
CSOURCES += dllmain.c
|
CSOURCES += dllmain.c
|
||||||
|
|
|
@ -46,7 +46,6 @@ target_include_directories(${BUNDLE} PRIVATE
|
||||||
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h", curlx
|
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h", curlx
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
|
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
|
||||||
)
|
)
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_NO_OLDIES")
|
|
||||||
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
|
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
|
||||||
|
|
||||||
curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${TESTS_C})
|
curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${TESTS_C})
|
||||||
|
|
|
@ -51,7 +51,6 @@ LIBS = $(BLANK_AT_MAKETIME)
|
||||||
if USE_CPPFLAG_CURL_STATICLIB
|
if USE_CPPFLAG_CURL_STATICLIB
|
||||||
AM_CPPFLAGS += -DCURL_STATICLIB
|
AM_CPPFLAGS += -DCURL_STATICLIB
|
||||||
endif
|
endif
|
||||||
AM_CPPFLAGS += -DCURL_NO_OLDIES
|
|
||||||
|
|
||||||
if USE_CPPFLAG_CURL_STATICLIB
|
if USE_CPPFLAG_CURL_STATICLIB
|
||||||
curlx_c_lib =
|
curlx_c_lib =
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
* SPDX-License-Identifier: curl
|
* SPDX-License-Identifier: curl
|
||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
#define CURL_NO_OLDIES
|
||||||
|
|
||||||
#include "curl_setup.h"
|
#include "curl_setup.h"
|
||||||
|
|
||||||
typedef int (*entry_func_t)(int, char **);
|
typedef int (*entry_func_t)(int, char **);
|
||||||
|
|
|
@ -55,8 +55,7 @@ target_include_directories(${BUNDLE} PRIVATE
|
||||||
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h", curlx
|
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h", curlx
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
|
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
|
||||||
)
|
)
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}")
|
target_compile_definitions(${BUNDLE} PRIVATE ${CURL_DEBUG_MACROS})
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_NO_OLDIES" "CURL_DISABLE_DEPRECATION")
|
|
||||||
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
|
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
|
||||||
|
|
||||||
curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${UTILS_C} ${TESTS_C})
|
curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${UTILS_C} ${TESTS_C})
|
||||||
|
|
|
@ -58,7 +58,6 @@ endif
|
||||||
if CURLDEBUG
|
if CURLDEBUG
|
||||||
AM_CPPFLAGS += -DCURLDEBUG
|
AM_CPPFLAGS += -DCURLDEBUG
|
||||||
endif
|
endif
|
||||||
AM_CPPFLAGS += -DCURL_NO_OLDIES -DCURL_DISABLE_DEPRECATION
|
|
||||||
|
|
||||||
if USE_CPPFLAG_CURL_STATICLIB
|
if USE_CPPFLAG_CURL_STATICLIB
|
||||||
curlx_c_lib =
|
curlx_c_lib =
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
* SPDX-License-Identifier: curl
|
* SPDX-License-Identifier: curl
|
||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
#define CURL_NO_OLDIES
|
||||||
|
#define CURL_DISABLE_DEPRECATION
|
||||||
|
|
||||||
/* Now include the curl_setup.h file from libcurl's private libdir (the source
|
/* Now include the curl_setup.h file from libcurl's private libdir (the source
|
||||||
version, but that might include "curl_config.h" from the build dir so we
|
version, but that might include "curl_config.h" from the build dir so we
|
||||||
need both of them in the include path), so that we get good in-depth
|
need both of them in the include path), so that we get good in-depth
|
||||||
|
|
|
@ -42,17 +42,6 @@ target_include_directories(${BUNDLE} PRIVATE
|
||||||
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h", curlx
|
"${PROJECT_SOURCE_DIR}/lib" # for "curl_setup.h", curlx
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
|
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
|
||||||
)
|
)
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "WITHOUT_LIBCURL")
|
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_NO_OLDIES")
|
|
||||||
# Test servers simply are standalone programs that do not use libcurl
|
|
||||||
# library. For convenience and to ease portability of these servers,
|
|
||||||
# some source code files from the libcurl subdirectory are also used
|
|
||||||
# to build the servers. In order to achieve proper linkage of these
|
|
||||||
# files on Windows targets it is necessary to build the test servers
|
|
||||||
# with CURL_STATICLIB defined, independently of how libcurl is built.
|
|
||||||
if(WIN32)
|
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_STATICLIB")
|
|
||||||
endif()
|
|
||||||
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
|
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
|
||||||
|
|
||||||
curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${UTILS_C} ${TESTS_C})
|
curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${UTILS_C} ${TESTS_C})
|
||||||
|
|
|
@ -48,12 +48,6 @@ CFLAGS += @CURL_CFLAG_EXTRAS@
|
||||||
# Prevent LIBS from being used for all link targets
|
# Prevent LIBS from being used for all link targets
|
||||||
LIBS = $(BLANK_AT_MAKETIME)
|
LIBS = $(BLANK_AT_MAKETIME)
|
||||||
|
|
||||||
AM_CPPFLAGS += -DWITHOUT_LIBCURL
|
|
||||||
AM_CPPFLAGS += -DCURL_NO_OLDIES
|
|
||||||
if DOING_NATIVE_WINDOWS
|
|
||||||
AM_CPPFLAGS += -DCURL_STATICLIB
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(BUNDLE).c: $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRST_C) $(UTILS_C) $(CURLX_C) $(TESTS_C)
|
$(BUNDLE).c: $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRST_C) $(UTILS_C) $(CURLX_C) $(TESTS_C)
|
||||||
@PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(UTILS_C) $(CURLX_C) --test $(TESTS_C) > $(BUNDLE).c
|
@PERL@ $(top_srcdir)/scripts/mk-unity.pl --include $(UTILS_C) $(CURLX_C) --test $(TESTS_C) > $(BUNDLE).c
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,20 @@
|
||||||
* SPDX-License-Identifier: curl
|
* SPDX-License-Identifier: curl
|
||||||
*
|
*
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
/* Test servers simply are standalone programs that do not use libcurl
|
||||||
|
* library. For convenience and to ease portability of these servers,
|
||||||
|
* some source code files from the libcurl subdirectory are also used
|
||||||
|
* to build the servers. In order to achieve proper linkage of these
|
||||||
|
* files on Windows targets it is necessary to build the test servers
|
||||||
|
* with CURL_STATICLIB defined, independently of how libcurl is built.
|
||||||
|
* For other platforms, this macro is a no-op and safe to set.
|
||||||
|
*/
|
||||||
|
#define CURL_STATICLIB
|
||||||
|
|
||||||
|
#define WITHOUT_LIBCURL
|
||||||
|
#define CURL_NO_OLDIES
|
||||||
|
|
||||||
#include "curl_setup.h"
|
#include "curl_setup.h"
|
||||||
|
|
||||||
typedef int (*entry_func_t)(int, char **);
|
typedef int (*entry_func_t)(int, char **);
|
||||||
|
|
|
@ -44,8 +44,7 @@ target_include_directories(${BUNDLE} PRIVATE
|
||||||
"${PROJECT_SOURCE_DIR}/tests/libtest" # for "first.h", "unitcheck.h"
|
"${PROJECT_SOURCE_DIR}/tests/libtest" # for "first.h", "unitcheck.h"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
|
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
|
||||||
)
|
)
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}")
|
target_compile_definitions(${BUNDLE} PRIVATE ${CURL_DEBUG_MACROS})
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_NO_OLDIES" "CURL_DISABLE_DEPRECATION")
|
|
||||||
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
|
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
|
||||||
|
|
||||||
curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${TESTS_C})
|
curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${TESTS_C})
|
||||||
|
|
|
@ -57,7 +57,6 @@ endif
|
||||||
if CURLDEBUG
|
if CURLDEBUG
|
||||||
AM_CPPFLAGS += -DCURLDEBUG
|
AM_CPPFLAGS += -DCURLDEBUG
|
||||||
endif
|
endif
|
||||||
AM_CPPFLAGS += -DCURL_NO_OLDIES -DCURL_DISABLE_DEPRECATION
|
|
||||||
|
|
||||||
if BUILD_UNITTESTS
|
if BUILD_UNITTESTS
|
||||||
$(BUNDLE).c: $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRST_C) $(TESTS_C)
|
$(BUNDLE).c: $(top_srcdir)/scripts/mk-unity.pl Makefile.inc $(FIRST_C) $(TESTS_C)
|
||||||
|
|
|
@ -44,10 +44,8 @@ target_include_directories(${BUNDLE} PRIVATE
|
||||||
"${PROJECT_SOURCE_DIR}/tests/libtest" # for "first.h", "unitcheck.h"
|
"${PROJECT_SOURCE_DIR}/tests/libtest" # for "first.h", "unitcheck.h"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
|
"${CMAKE_CURRENT_SOURCE_DIR}" # for the generated bundle source to find included test sources
|
||||||
)
|
)
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "${CURL_DEBUG_MACROS}")
|
# unit tests are small pretend-libcurl-programs, pass BUILDING_LIBCURL to reflect that
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_NO_OLDIES" "CURL_DISABLE_DEPRECATION")
|
target_compile_definitions(${BUNDLE} PRIVATE ${CURL_DEBUG_MACROS} "BUILDING_LIBCURL")
|
||||||
# unit tests are small pretend-libcurl-programs
|
|
||||||
set_property(TARGET ${BUNDLE} APPEND PROPERTY COMPILE_DEFINITIONS "BUILDING_LIBCURL")
|
|
||||||
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
|
set_target_properties(${BUNDLE} PROPERTIES OUTPUT_NAME "${BUNDLE}" PROJECT_LABEL "Test ${BUNDLE}" UNITY_BUILD OFF C_CLANG_TIDY "")
|
||||||
|
|
||||||
curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${TESTS_C})
|
curl_add_clang_tidy_test_target("${BUNDLE}-clang-tidy" ${BUNDLE} ${FIRST_C} ${TESTS_C})
|
||||||
|
|
|
@ -56,7 +56,7 @@ endif
|
||||||
if CURLDEBUG
|
if CURLDEBUG
|
||||||
AM_CPPFLAGS += -DCURLDEBUG
|
AM_CPPFLAGS += -DCURLDEBUG
|
||||||
endif
|
endif
|
||||||
AM_CPPFLAGS += -DCURL_NO_OLDIES -DCURL_DISABLE_DEPRECATION
|
# unit tests are small pretend-libcurl-programs, pass BUILDING_LIBCURL to reflect that
|
||||||
AM_CPPFLAGS += -DBUILDING_LIBCURL
|
AM_CPPFLAGS += -DBUILDING_LIBCURL
|
||||||
|
|
||||||
if BUILD_UNITTESTS
|
if BUILD_UNITTESTS
|
||||||
|
|
Loading…
Reference in New Issue
Block a user