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:
Charlie C 2023-11-06 14:19:00 -07:00 committed by Viktor Szakats
parent 45d2ff6f85
commit aace27b096
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
2 changed files with 256 additions and 246 deletions

View file

@ -47,20 +47,25 @@ if(USE_ARES)
include_directories(${CARES_INCLUDE_DIR})
endif()
add_library(
curlu # special libcurlu library just for unittests
STATIC
EXCLUDE_FROM_ALL
${HHEADERS} ${CSOURCES}
)
target_compile_definitions(curlu PUBLIC UNITTESTS CURL_STATICLIB)
if(BUILD_TESTING)
add_library(
curlu # special libcurlu library just for unittests
STATIC
EXCLUDE_FROM_ALL
${HHEADERS} ${CSOURCES}
)
target_compile_definitions(curlu PUBLIC UNITTESTS CURL_STATICLIB)
endif()
if(ENABLE_CURLDEBUG)
# We must compile these sources separately to avoid memdebug.h redefinitions
# applying to them.
set_source_files_properties(memdebug.c curl_multibyte.c PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
endif()
target_link_libraries(curlu PRIVATE ${CURL_LIBS})
if(BUILD_TESTING)
target_link_libraries(curlu PRIVATE ${CURL_LIBS})
endif()
transform_makefile_inc("Makefile.soname" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.soname.cmake")
include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.soname.cmake)