2012-08-14 23:49:39 +04:00
|
|
|
# WinPR: Windows Portable Runtime
|
|
|
|
# winpr cmake build script
|
|
|
|
#
|
|
|
|
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2018-05-02 09:40:30 +03:00
|
|
|
include(CheckFunctionExists)
|
|
|
|
|
2014-07-10 02:03:20 +04:00
|
|
|
set(WINPR_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(WINPR_SRCS "")
|
2019-03-15 13:36:24 +03:00
|
|
|
set(WINPR_LIBS_PRIVATE "")
|
|
|
|
set(WINPR_LIBS_PUBLIC "")
|
2014-07-10 02:03:20 +04:00
|
|
|
set(WINPR_INCLUDES "")
|
|
|
|
set(WINPR_DEFINITIONS "")
|
2023-02-25 10:48:11 +03:00
|
|
|
set(WINPR_COMPILE_OPTIONS "")
|
|
|
|
set(WINPR_LINK_OPTIONS "")
|
|
|
|
set(WINPR_LINK_DIRS "")
|
2012-08-14 23:49:39 +04:00
|
|
|
|
2014-07-10 02:03:20 +04:00
|
|
|
macro (winpr_module_add)
|
|
|
|
file (RELATIVE_PATH _relPath "${WINPR_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
foreach (_src ${ARGN})
|
|
|
|
if (_relPath)
|
|
|
|
list (APPEND WINPR_SRCS "${_relPath}/${_src}")
|
|
|
|
else()
|
|
|
|
list (APPEND WINPR_SRCS "${_src}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if (_relPath)
|
|
|
|
set (WINPR_SRCS ${WINPR_SRCS} PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2012-10-04 03:50:48 +04:00
|
|
|
|
2014-07-10 02:03:20 +04:00
|
|
|
macro (winpr_include_directory_add)
|
|
|
|
file (RELATIVE_PATH _relPath "${WINPR_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
|
2014-07-10 19:40:27 +04:00
|
|
|
foreach (_inc ${ARGN})
|
2015-08-19 10:02:20 +03:00
|
|
|
if (IS_ABSOLUTE ${_inc})
|
|
|
|
list (APPEND WINPR_INCLUDES "${_inc}")
|
|
|
|
else()
|
|
|
|
if (_relPath)
|
|
|
|
list (APPEND WINPR_INCLUDES "${_relPath}/${_inc}")
|
|
|
|
else()
|
|
|
|
list (APPEND WINPR_INCLUDES "${_inc}")
|
|
|
|
endif()
|
|
|
|
endif()
|
2014-07-10 02:03:20 +04:00
|
|
|
endforeach()
|
|
|
|
if (_relPath)
|
|
|
|
set (WINPR_INCLUDES ${WINPR_INCLUDES} PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2012-10-04 03:29:28 +04:00
|
|
|
|
2019-03-15 13:36:24 +03:00
|
|
|
macro (winpr_library_add_private)
|
2014-07-10 02:03:20 +04:00
|
|
|
foreach (_lib ${ARGN})
|
2019-03-15 13:36:24 +03:00
|
|
|
list (APPEND WINPR_LIBS_PRIVATE "${_lib}")
|
2014-07-10 02:03:20 +04:00
|
|
|
endforeach()
|
2019-03-15 13:36:24 +03:00
|
|
|
set (WINPR_LIBS_PRIVATE ${WINPR_LIBS_PRIVATE} PARENT_SCOPE)
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro (winpr_library_add_public)
|
|
|
|
foreach (_lib ${ARGN})
|
|
|
|
list (APPEND WINPR_LIBS_PUBLIC "${_lib}")
|
|
|
|
endforeach()
|
|
|
|
set (WINPR_LIBS_PUBLIC ${WINPR_LIBS_PUBLIC} PARENT_SCOPE)
|
2014-07-10 02:03:20 +04:00
|
|
|
endmacro()
|
2012-08-14 23:49:39 +04:00
|
|
|
|
2014-07-10 02:03:20 +04:00
|
|
|
macro (winpr_definition_add)
|
|
|
|
foreach (_define ${ARGN})
|
|
|
|
list (APPEND WINPR_DEFINITIONS "${_define}")
|
|
|
|
endforeach()
|
|
|
|
set (WINPR_DEFINITIONS ${WINPR_DEFINITIONS} PARENT_SCOPE)
|
|
|
|
endmacro()
|
2012-10-04 03:29:28 +04:00
|
|
|
|
2023-02-25 10:48:11 +03:00
|
|
|
macro (winpr_library_add_compile_options)
|
|
|
|
foreach (_define ${ARGN})
|
|
|
|
list (APPEND WINPR_COMPILE_OPTIONS "${_define}")
|
|
|
|
endforeach()
|
|
|
|
set (WINPR_COMPILE_OPTIONS ${WINPR_COMPILE_OPTIONS} PARENT_SCOPE)
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro (winpr_library_add_link_options)
|
|
|
|
foreach (_define ${ARGN})
|
|
|
|
list (APPEND WINPR_LINK_OPTIONS "${_define}")
|
|
|
|
endforeach()
|
|
|
|
set (WINPR_LINK_OPTIONS ${WINPR_LINK_OPTIONS} PARENT_SCOPE)
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro (winpr_library_add_link_directory)
|
|
|
|
foreach (_define ${ARGN})
|
|
|
|
list (APPEND WINPR_LINK_DIRS "${_define}")
|
|
|
|
endforeach()
|
|
|
|
set (WINPR_LINK_DIRS ${WINPR_LINK_DIRS} PARENT_SCOPE)
|
|
|
|
endmacro()
|
|
|
|
|
2018-05-02 09:40:30 +03:00
|
|
|
set(CMAKE_REQUIRED_LIBRARIES rt)
|
2021-05-27 23:23:25 +03:00
|
|
|
|
|
|
|
if(NOT IOS)
|
|
|
|
check_function_exists(timer_create TIMER_CREATE)
|
|
|
|
check_function_exists(timer_delete TIMER_DELETE)
|
|
|
|
check_function_exists(timer_settime TIMER_SETTIME)
|
|
|
|
check_function_exists(timer_gettime TIMER_GETTIME)
|
|
|
|
if (TIMER_CREATE AND TIMER_DELETE AND TIMER_SETTIME AND TIMER_GETTIME)
|
|
|
|
add_definitions(-DWITH_POSIX_TIMER)
|
|
|
|
winpr_library_add_private(rt)
|
|
|
|
endif()
|
2018-05-02 09:40:30 +03:00
|
|
|
endif()
|
|
|
|
|
2016-02-01 17:21:07 +03:00
|
|
|
if (ANDROID)
|
2019-03-15 13:36:24 +03:00
|
|
|
winpr_library_add_private(log)
|
2016-02-01 17:21:07 +03:00
|
|
|
endif()
|
|
|
|
|
2014-07-10 02:03:20 +04:00
|
|
|
# Level "1" API as defined for MinCore.lib
|
2021-07-29 11:38:07 +03:00
|
|
|
set(WINPR_CORE synch library file comm pipe interlocked security
|
2021-12-20 15:23:45 +03:00
|
|
|
environment crypto registry path io memory ncrypt input shell
|
2021-12-20 15:29:48 +03:00
|
|
|
utils error timezone sysinfo pool handle thread)
|
2012-10-04 03:29:28 +04:00
|
|
|
|
2014-07-10 02:03:20 +04:00
|
|
|
foreach(DIR ${WINPR_CORE})
|
|
|
|
add_subdirectory(${DIR})
|
2016-06-15 14:54:31 +03:00
|
|
|
source_group("${DIR}" REGULAR_EXPRESSION "${DIR}/.*\\.[ch]")
|
2014-07-10 02:03:20 +04:00
|
|
|
endforeach()
|
2012-08-15 03:55:48 +04:00
|
|
|
|
2021-12-20 14:19:04 +03:00
|
|
|
set(WINPR_LEVEL2 winsock sspi sspicli crt bcrypt rpc
|
2021-12-20 14:08:47 +03:00
|
|
|
wtsapi dsparse smartcard nt clipboard)
|
2012-08-14 23:49:39 +04:00
|
|
|
|
2014-07-10 02:03:20 +04:00
|
|
|
foreach(DIR ${WINPR_LEVEL2})
|
|
|
|
add_subdirectory(${DIR})
|
2016-06-15 14:54:31 +03:00
|
|
|
source_group("${DIR}" REGULAR_EXPRESSION "${DIR}/.*\\.[ch]")
|
2014-07-10 02:03:20 +04:00
|
|
|
endforeach()
|
2013-07-26 05:59:21 +04:00
|
|
|
|
2014-07-10 02:03:20 +04:00
|
|
|
set(MODULE_NAME winpr)
|
|
|
|
list(REMOVE_DUPLICATES WINPR_DEFINITIONS)
|
2023-02-25 10:48:11 +03:00
|
|
|
list(REMOVE_DUPLICATES WINPR_COMPILE_OPTIONS)
|
|
|
|
list(REMOVE_DUPLICATES WINPR_LINK_OPTIONS)
|
|
|
|
list(REMOVE_DUPLICATES WINPR_LINK_DIRS)
|
2019-03-15 13:36:24 +03:00
|
|
|
list(REMOVE_DUPLICATES WINPR_LIBS_PRIVATE)
|
|
|
|
list(REMOVE_DUPLICATES WINPR_LIBS_PUBLIC)
|
2014-07-10 02:03:20 +04:00
|
|
|
list(REMOVE_DUPLICATES WINPR_INCLUDES)
|
2014-10-03 17:17:40 +04:00
|
|
|
|
|
|
|
# On windows create dll version information.
|
|
|
|
# Vendor, product and year are already set in top level CMakeLists.txt
|
|
|
|
if (WIN32)
|
|
|
|
set (RC_VERSION_MAJOR ${WINPR_VERSION_MAJOR})
|
|
|
|
set (RC_VERSION_MINOR ${WINPR_VERSION_MINOR})
|
|
|
|
set (RC_VERSION_BUILD ${WINPR_VERSION_REVISION})
|
2021-06-10 10:54:35 +03:00
|
|
|
set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${WINPR_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" )
|
2014-10-03 17:17:40 +04:00
|
|
|
|
|
|
|
configure_file(
|
2021-06-21 12:39:34 +03:00
|
|
|
${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in
|
2014-10-03 17:17:40 +04:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/version.rc
|
|
|
|
@ONLY)
|
|
|
|
|
|
|
|
set (WINPR_SRCS ${WINPR_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
2019-03-15 13:36:24 +03:00
|
|
|
winpr_library_add_public("shlwapi")
|
2014-10-03 17:17:40 +04:00
|
|
|
endif()
|
|
|
|
|
2014-07-10 02:03:20 +04:00
|
|
|
add_library(${MODULE_NAME} ${WINPR_SRCS})
|
2022-05-25 16:50:25 +03:00
|
|
|
if (APPLE)
|
|
|
|
set_target_properties(${MODULE_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION FALSE)
|
|
|
|
endif()
|
2014-07-10 02:03:20 +04:00
|
|
|
set_target_properties(${MODULE_NAME} PROPERTIES LINKER_LANGUAGE C)
|
2016-12-21 17:25:03 +03:00
|
|
|
set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${WINPR_API_VERSION})
|
2014-04-29 11:42:18 +04:00
|
|
|
if (WITH_LIBRARY_VERSIONING)
|
2016-01-13 19:37:19 +03:00
|
|
|
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION} SOVERSION ${WINPR_API_VERSION})
|
2014-04-29 11:42:18 +04:00
|
|
|
endif()
|
2014-09-15 12:30:07 +04:00
|
|
|
|
2023-02-25 10:48:11 +03:00
|
|
|
target_link_options(${MODULE_NAME} PRIVATE ${WINPR_LINK_OPTIONS})
|
|
|
|
target_include_directories(${MODULE_NAME} PRIVATE ${WINPR_INCLUDES})
|
|
|
|
target_link_directories(${MODULE_NAME} PRIVATE ${WINPR_LINK_DIRS})
|
|
|
|
target_compile_options(${MODULE_NAME} PRIVATE ${WINPR_COMPILE_OPTIONS})
|
|
|
|
target_compile_definitions(${MODULE_NAME} PRIVATE ${WINPR_DEFINITIONS})
|
|
|
|
|
2021-06-10 10:54:35 +03:00
|
|
|
target_link_libraries(${MODULE_NAME} PRIVATE ${WINPR_LIBS_PRIVATE} PUBLIC ${WINPR_LIBS_PUBLIC})
|
2021-05-24 07:51:42 +03:00
|
|
|
install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT WinPRTargets
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
|
2015-07-31 12:35:54 +03:00
|
|
|
if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS)
|
2017-01-31 15:32:51 +03:00
|
|
|
get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME)
|
|
|
|
install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols)
|
2015-07-31 12:35:54 +03:00
|
|
|
endif()
|
2014-07-10 02:03:20 +04:00
|
|
|
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/libwinpr")
|