cmake: option to disable install & drop curlu target when unused
This patch makes the following changes: - adds the option `CURL_DISABLE_INSTALL` - to disable 'install' targets. - Removes the target `curlu` when the option `BUILD_TESTING` is set to `OFF` - to prevent it from being loaded in Visual Studio. Closes #12287
This commit is contained in:
parent
45d2ff6f85
commit
aace27b096
@ -105,6 +105,8 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
|||||||
option(BUILD_STATIC_LIBS "Build static libraries" OFF)
|
option(BUILD_STATIC_LIBS "Build static libraries" OFF)
|
||||||
option(BUILD_STATIC_CURL "Build curl executable with static libcurl" OFF)
|
option(BUILD_STATIC_CURL "Build curl executable with static libcurl" OFF)
|
||||||
option(ENABLE_ARES "Set to ON to enable c-ares support" OFF)
|
option(ENABLE_ARES "Set to ON to enable c-ares support" OFF)
|
||||||
|
option(CURL_DISABLE_INSTALL "Set to ON to disable instalation targets" OFF)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
option(CURL_STATIC_CRT "Set to ON to build libcurl with static CRT on Windows (/MT)." OFF)
|
option(CURL_STATIC_CRT "Set to ON to build libcurl with static CRT on Windows (/MT)." OFF)
|
||||||
option(ENABLE_UNICODE "Set to ON to use the Unicode version of the Windows API functions" OFF)
|
option(ENABLE_UNICODE "Set to ON to use the Unicode version of the Windows API functions" OFF)
|
||||||
@ -1523,6 +1525,8 @@ if(BUILD_TESTING)
|
|||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT CURL_DISABLE_INSTALL)
|
||||||
|
|
||||||
# Helper to populate a list (_items) with a label when conditions (the remaining
|
# Helper to populate a list (_items) with a label when conditions (the remaining
|
||||||
# args) are satisfied
|
# args) are satisfied
|
||||||
macro(_add_if label)
|
macro(_add_if label)
|
||||||
@ -1779,3 +1783,4 @@ if(NOT TARGET curl_uninstall)
|
|||||||
COMMAND ${CMAKE_COMMAND} -P
|
COMMAND ${CMAKE_COMMAND} -P
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake)
|
${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|||||||
@ -47,6 +47,7 @@ if(USE_ARES)
|
|||||||
include_directories(${CARES_INCLUDE_DIR})
|
include_directories(${CARES_INCLUDE_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
add_library(
|
add_library(
|
||||||
curlu # special libcurlu library just for unittests
|
curlu # special libcurlu library just for unittests
|
||||||
STATIC
|
STATIC
|
||||||
@ -54,13 +55,17 @@ add_library(
|
|||||||
${HHEADERS} ${CSOURCES}
|
${HHEADERS} ${CSOURCES}
|
||||||
)
|
)
|
||||||
target_compile_definitions(curlu PUBLIC UNITTESTS CURL_STATICLIB)
|
target_compile_definitions(curlu PUBLIC UNITTESTS CURL_STATICLIB)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_CURLDEBUG)
|
if(ENABLE_CURLDEBUG)
|
||||||
# We must compile these sources separately to avoid memdebug.h redefinitions
|
# We must compile these sources separately to avoid memdebug.h redefinitions
|
||||||
# applying to them.
|
# applying to them.
|
||||||
set_source_files_properties(memdebug.c curl_multibyte.c PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
set_source_files_properties(memdebug.c curl_multibyte.c PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
target_link_libraries(curlu PRIVATE ${CURL_LIBS})
|
target_link_libraries(curlu PRIVATE ${CURL_LIBS})
|
||||||
|
endif()
|
||||||
|
|
||||||
transform_makefile_inc("Makefile.soname" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.soname.cmake")
|
transform_makefile_inc("Makefile.soname" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.soname.cmake")
|
||||||
include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.soname.cmake)
|
include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.soname.cmake)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user