From 678ff144abeb1b80e41e9f0185771958662b436f Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 19 Mar 2024 12:19:07 +0100 Subject: [PATCH] [cmake] unify windows resource file generation * use a macro to add resource files for executables and shared libraries * use that macro to declare targets * use that macro to set library/binary versioning * use that macro to set target output name * use a macro to create manpages and names --- CMakeLists.txt | 8 -- channels/server/CMakeLists.txt | 5 - client/SDL/CMakeLists.txt | 10 +- client/SDL/man/CMakeLists.txt | 6 +- client/Sample/CMakeLists.txt | 21 +-- client/Wayland/CMakeLists.txt | 10 +- client/Windows/CMakeLists.txt | 56 +------- client/Windows/cli/CMakeLists.txt | 24 +--- client/X11/CMakeLists.txt | 30 +---- client/X11/cli/CMakeLists.txt | 21 +-- client/X11/man/CMakeLists.txt | 6 +- client/common/CMakeLists.txt | 28 +--- cmake/AddTargetWithResourceFile.cmake | 120 ++++++++++++++++++ cmake/CommonConfigOptions.cmake | 2 +- cmake/ConfigOptions.cmake | 1 + cmake/ConfigureRPATH.cmake | 10 +- cmake/InstallFreeRDPMan.cmake | 33 ++++- libfreerdp/CMakeLists.txt | 29 +---- rdtk/librdtk/CMakeLists.txt | 29 +---- rdtk/sample/CMakeLists.txt | 5 +- server/Sample/CMakeLists.txt | 24 +--- server/Windows/CMakeLists.txt | 39 +----- server/Windows/cli/CMakeLists.txt | 28 +--- server/common/CMakeLists.txt | 29 +---- server/proxy/CMakeLists.txt | 29 +---- server/proxy/cli/CMakeLists.txt | 35 +---- .../modules/bitmap-filter/CMakeLists.txt | 6 +- server/proxy/modules/demo/CMakeLists.txt | 6 +- .../modules/dyn-channel-dump/CMakeLists.txt | 6 +- server/shadow/CMakeLists.txt | 88 +------------ winpr/CMakeLists.txt | 7 +- winpr/libwinpr/CMakeLists.txt | 27 +--- winpr/libwinpr/path/CMakeLists.txt | 4 + winpr/libwinpr/path/shell.c | 6 - winpr/tools/CMakeLists.txt | 27 +--- winpr/tools/hash-cli/CMakeLists.txt | 30 +---- winpr/tools/makecert-cli/CMakeLists.txt | 32 +---- winpr/tools/makecert/CMakeLists.txt | 8 +- 38 files changed, 215 insertions(+), 670 deletions(-) create mode 100644 cmake/AddTargetWithResourceFile.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 36c72ab8a..49c61703a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -367,14 +367,6 @@ if(WIN32) set(CMAKE_DL_LIBS "") set(CMAKE_USE_RELATIVE_PATH ON) - if (${CMAKE_GENERATOR} MATCHES "NMake Makefile*" OR ${CMAKE_GENERATOR} MATCHES "Ninja*" OR ${CMAKE_GENERATOR} MATCHES "Unix Makefiles") - set(CMAKE_PDB_BINARY_DIR ${PROJECT_BINARY_DIR}) - elseif (${CMAKE_GENERATOR} MATCHES "Visual Studio*") - set(CMAKE_PDB_BINARY_DIR "${PROJECT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}") - else() - message(FATAL_ERROR "Unknown generator ${CMAKE_GENERATOR}") - endif() - string(TIMESTAMP RC_VERSION_YEAR "%Y") if(NOT DEFINED CMAKE_WINDOWS_VERSION) diff --git a/channels/server/CMakeLists.txt b/channels/server/CMakeLists.txt index 1f49c3bd4..8ffb18468 100644 --- a/channels/server/CMakeLists.txt +++ b/channels/server/CMakeLists.txt @@ -30,11 +30,6 @@ endforeach() add_library(${MODULE_NAME} STATIC ${${MODULE_PREFIX}_SRCS}) -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() - - set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} PARENT_SCOPE) diff --git a/client/SDL/CMakeLists.txt b/client/SDL/CMakeLists.txt index 6d2b778c5..0b3aa1bc0 100644 --- a/client/SDL/CMakeLists.txt +++ b/client/SDL/CMakeLists.txt @@ -46,7 +46,7 @@ option(WITH_WIN_CONSOLE "Build ${PROJECT_NAME} with console support" ON) option(WITH_SDL_LINK_SHARED "link SDL dynamic or static" ON) if(WITH_WIN_CONSOLE) - set(WIN32_GUI_FLAG "") + set(WIN32_GUI_FLAG "TRUE") else() set(WIN32_GUI_FLAG "WIN32") endif() @@ -113,14 +113,8 @@ else() list(APPEND LIBS ${SDL2_LIBRARIES}) endif() -add_executable(${PROJECT_NAME} - ${WIN32_GUI_FLAG} - ${SRCS} - ) +AddTargetWithResourceFile(${PROJECT_NAME} "${WIN32_GUI_FLAG}" "${PROJECT_VERSION}" SRCS) -if (WITH_BINARY_VERSIONING) - set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}${PROJECT_VERSION_MAJOR}") -endif() target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBS}) set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER "Client/SDL") install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) diff --git a/client/SDL/man/CMakeLists.txt b/client/SDL/man/CMakeLists.txt index 1fb2adcf9..e2dfd7ac5 100644 --- a/client/SDL/man/CMakeLists.txt +++ b/client/SDL/man/CMakeLists.txt @@ -5,8 +5,4 @@ set(DEPS sdl-freerdp-envvar.1.xml ) -set(MANPAGE_NAME ${PROJECT_NAME}) -if (WITH_BINARY_VERSIONING) - set(MANPAGE_NAME ${PROJECT_NAME}${PROJECT_VERSION_MAJOR}) -endif() -generate_and_install_freerdp_man_from_xml(${PROJECT_NAME}.1 ${MANPAGE_NAME}.1 "${DEPS}") +generate_and_install_freerdp_man_from_xml(${PROJECT_NAME} "1" "${FREERDP_API_VERSION}" "${DEPS}") diff --git a/client/Sample/CMakeLists.txt b/client/Sample/CMakeLists.txt index db4e947ac..dfef11b93 100644 --- a/client/Sample/CMakeLists.txt +++ b/client/Sample/CMakeLists.txt @@ -45,23 +45,7 @@ set(SRCS tf_freerdp.h tf_freerdp.c) -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/../../cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - -list (APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_executable(${PROJECT_NAME} ${SRCS}) +AddTargetWithResourceFile(${PROJECT_NAME} TRUE "${PROJECT_VERSION}" SRCS) set(LIBS freerdp-client @@ -70,8 +54,5 @@ set(LIBS ) target_link_libraries(${PROJECT_NAME} PRIVATE ${LIBS}) -if (WITH_BINARY_VERSIONING) - set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}${PROJECT_VERSION_MAJOR}") -endif() set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER "Client/Sample") install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) diff --git a/client/Wayland/CMakeLists.txt b/client/Wayland/CMakeLists.txt index 7076ff150..41226ba83 100644 --- a/client/Wayland/CMakeLists.txt +++ b/client/Wayland/CMakeLists.txt @@ -46,17 +46,11 @@ endif() list (APPEND ${MODULE_PREFIX}_LIBS freerdp-client freerdp uwac) -add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +AddTargetWithResourceFile(${MODULE_NAME} TRUE ${FREERDP_VERSION} ${MODULE_PREFIX}_SRCS) -set(MANPAGE_NAME ${MODULE_NAME}) -if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${MODULE_NAME}${FREERDP_API_VERSION}") - set(MANPAGE_NAME ${MODULE_NAME}${FREERDP_API_VERSION}) -endif() target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Wayland") -configure_file(wlfreerdp.1.in ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.1) -install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.1 1) +generate_and_install_freerdp_man_from_template(${MODULE_NAME} "1" "${FREERDP_API_VERSION}") diff --git a/client/Windows/CMakeLists.txt b/client/Windows/CMakeLists.txt index 816375340..1cd0dc210 100644 --- a/client/Windows/CMakeLists.txt +++ b/client/Windows/CMakeLists.txt @@ -40,26 +40,6 @@ set(${MODULE_PREFIX}_SRCS resource/wfreerdp.rc resource/resource.h) -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32 AND BUILD_SHARED_LIBS) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - if(WITH_CLIENT_INTERFACE) - set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${FREERDP_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) - else() - set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" ) - endif() - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set ( ${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - option(WITH_WINDOWS_CERT_STORE "Build ${MODULE_NAME} with additional certificate validation against windows certificate store" ON) if(WITH_WINDOWS_CERT_STORE) add_definitions("-DWITH_WINDOWS_CERT_STORE") @@ -68,7 +48,7 @@ endif() option(WITH_WIN_CONSOLE "Build ${MODULE_NAME} with console support" OFF) if(WITH_WIN_CONSOLE) add_definitions("-DWITH_WIN_CONSOLE") - set(WIN32_GUI_FLAG "") + set(WIN32_GUI_FLAG "TRUE") else() set(WIN32_GUI_FLAG "WIN32") endif() @@ -78,27 +58,12 @@ if(WITH_PROGRESS_BAR) add_definitions("-DWITH_PROGRESS_BAR") endif() -if(WITH_CLIENT_INTERFACE) - if(CLIENT_INTERFACE_SHARED) - add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS}) - else() - add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) - endif() - if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) - endif() - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${FREERDP_API_VERSION}) - target_include_directories(${MODULE_NAME} INTERFACE $) +if(CLIENT_INTERFACE_SHARED) + AddTargetWithResourceFile(${MODULE_NAME} "SHARED" "${FREERDP_VERSION}" ${MODULE_PREFIX}_SRCS) else() - set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} cli/wfreerdp.c cli/wfreerdp.h) - add_executable(${MODULE_NAME} ${WIN32_GUI_FLAG} ${${MODULE_PREFIX}_SRCS}) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "wfreerdp${FREERDP_API_VERSION}") - else() - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "wfreerdp") - endif() + AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" ${MODULE_PREFIX}_SRCS) endif() +target_include_directories(${MODULE_NAME} INTERFACE $) list(APPEND LIBS freerdp-client) list(APPEND LIBS winpr freerdp) @@ -112,16 +77,7 @@ target_link_libraries(${MODULE_NAME} PRIVATE ${LIBS}) if(WITH_CLIENT_INTERFACE) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) - if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${MODULE_NAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) - endif() - add_subdirectory(cli) -else() - install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) - if (WITH_DEBUG_SYMBOLS AND MSVC) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols) - endif() endif() +add_subdirectory(cli) set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Windows") diff --git a/client/Windows/cli/CMakeLists.txt b/client/Windows/cli/CMakeLists.txt index d418ff3e8..5ea186b4e 100644 --- a/client/Windows/cli/CMakeLists.txt +++ b/client/Windows/cli/CMakeLists.txt @@ -25,33 +25,11 @@ set(${MODULE_PREFIX}_SRCS wfreerdp.h ../resource/wfreerdp.rc) -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" ) +AddTargetWithResourceFile(${MODULE_NAME} "${WIN32_GUI_FLAG}" "${FREERDP_VERSION}" ${MODULE_PREFIX}_SRCS) - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set ( ${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() -add_executable(${MODULE_NAME} ${WIN32_GUI_FLAG} ${${MODULE_PREFIX}_SRCS}) - -if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${MODULE_NAME}${PROJECT_VERSION_MAJOR}") -endif() set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} wfreerdp-client) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) -if (WITH_DEBUG_SYMBOLS AND MSVC) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${MODULE_NAME}.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Windows") diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 099d00d42..180af1507 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -21,7 +21,7 @@ if (NOT FREERDP_DEFAULT_PROJECT_VERSION) set(FREERDP_DEFAULT_PROJECT_VERSION "1.0.0.0") endif() -project(xfreerdp +project(xfreerdp-client LANGUAGES C VERSION ${FREERDP_DEFAULT_PROJECT_VERSION} ) @@ -84,27 +84,12 @@ if (CHANNEL_TSMF_CLIENT) ) endif() -if(WITH_CLIENT_INTERFACE) - if(CLIENT_INTERFACE_SHARED) - add_library(${PROJECT_NAME} SHARED ${SRCS}) - if (WITH_LIBRARY_VERSIONING) - set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) - endif() - else() - add_library(${PROJECT_NAME} ${SRCS}) - endif() - target_include_directories(${PROJECT_NAME} INTERFACE $) - +if(CLIENT_INTERFACE_SHARED) + AddTargetWithResourceFile(${PROJECT_NAME} "SHARED" "${PROJECT_VERSION}" SRCS) else() - list(APPEND SRCS - cli/xfreerdp.c xfreerdp.h - ) - add_executable(${PROJECT_NAME} ${SRCS}) - if (WITH_BINARY_VERSIONING) - set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}${PROJECT_VERSION_MAJOR}") - endif() - include_directories(..) + AddTargetWithResourceFile(${PROJECT_NAME} "STATIC" "${PROJECT_VERSION}" SRCS) endif() +target_include_directories(${PROJECT_NAME} INTERFACE $) set(LIBS ${X11_LIBRARIES} @@ -233,13 +218,10 @@ if(WITH_IPP) target_link_libraries(${PROJECT_NAME} PRIVATE ${IPP_LIBRARY_LIST}) endif() -option(WITH_CLIENT_INTERFACE "Build clients as a library with an interface" OFF) if(WITH_CLIENT_INTERFACE) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) - add_subdirectory(cli) -else() - install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) endif() +add_subdirectory(cli) set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER "Client/X11") diff --git a/client/X11/cli/CMakeLists.txt b/client/X11/cli/CMakeLists.txt index 580337b34..f73805f41 100644 --- a/client/X11/cli/CMakeLists.txt +++ b/client/X11/cli/CMakeLists.txt @@ -15,32 +15,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(MODULE_NAME "xfreerdp-cli") +set(MODULE_NAME "xfreerdp") set(MODULE_PREFIX "FREERDP_CLIENT_X11") set(SRCS - xfreerdp.c + xfreerdp.c ) -add_executable(${MODULE_NAME} ${SRCS}) - -if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp${PROJECT_VERSION_MAJOR}") -else() - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp") -endif() +AddTargetWithResourceFile(${MODULE_NAME} TRUE "${PROJECT_VERSION}" SRCS) set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "..") list(APPEND LIBS - xfreerdp-client freerdp-client + xfreerdp-client + freerdp-client ) -if(OPENBSD) - list(APPEND LIBS - ossaudio - ) -endif() - target_link_libraries(${MODULE_NAME} PRIVATE ${LIBS}) install(TARGETS ${MODULE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) diff --git a/client/X11/man/CMakeLists.txt b/client/X11/man/CMakeLists.txt index d6d2fe979..ed50e63f7 100644 --- a/client/X11/man/CMakeLists.txt +++ b/client/X11/man/CMakeLists.txt @@ -5,8 +5,4 @@ set(DEPS xfreerdp-envvar.1.xml ) -set(MANPAGE_NAME ${PROJECT_NAME}) -if (WITH_BINARY_VERSIONING) - set(MANPAGE_NAME ${PROJECT_NAME}${PROJECT_VERSION_MAJOR}) -endif() -generate_and_install_freerdp_man_from_xml(${PROJECT_NAME}.1 ${MANPAGE_NAME}.1 ${DEPS}) +generate_and_install_freerdp_man_from_xml("xfreerdp" "1" "${FREERDP_API_VERSION}" ${DEPS}) diff --git a/client/common/CMakeLists.txt b/client/common/CMakeLists.txt index 6040bf334..177353395 100644 --- a/client/common/CMakeLists.txt +++ b/client/common/CMakeLists.txt @@ -58,30 +58,9 @@ if(WITH_FUSE) add_definitions(-D_FILE_OFFSET_BITS=64) endif() -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32 AND BUILD_SHARED_LIBS) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${FREERDP_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - -list (APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - include_directories(${OPENSSL_INCLUDE_DIR}) -add_library(${MODULE_NAME} ${SRCS}) - -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${FREERDP_API_VERSION}) -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() +AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" SRCS) list(APPEND LIBS freerdp winpr) @@ -94,11 +73,6 @@ install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT FreeRDP-ClientTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Common") if(BUILD_TESTING) diff --git a/cmake/AddTargetWithResourceFile.cmake b/cmake/AddTargetWithResourceFile.cmake new file mode 100644 index 000000000..3a160a355 --- /dev/null +++ b/cmake/AddTargetWithResourceFile.cmake @@ -0,0 +1,120 @@ +set(add_resource_macro_internal_dir ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "") + +macro(AddTargetWithResourceFile nameAndTarget is_exe version sources) + list(LENGTH ${nameAndTarget} target_length) + if (target_length GREATER 1) + list(GET ${nameAndTarget} 1 name) + list(GET ${nameAndTarget} 0 target) + else() + set(name ${nameAndTarget}) + set(target ${nameAndTarget}) + endif() + + set(VERSIONING OFF) + set(IS_EXE OFF) + if ("${is_exe}" MATCHES "TRUE") + set(IS_EXE ON) + elseif ("${is_exe}" MATCHES "WIN32") + set(IS_EXE ON) + set(exe_options "WIN32") + elseif ("${is_exe}" MATCHES "SHARED") + set(lib_options "SHARED") + elseif ("${is_exe}" MATCHES "STATIC") + set(lib_options "STATIC") + endif() + + if (IS_EXE AND WITH_BINARY_VERSIONING) + set(VERSIONING ON) + elseif (NOT IS_EXE AND WITH_LIBRARY_VERSIONING) + set(VERSIONING ON) + endif() + if (${ARGC} GREATER 4) + set(VERSIONING ${ARGV5}) + endif() + + string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*" + RC_PROGRAM_VERSION_MATCH ${version}) + set (RC_VERSION_MAJOR ${CMAKE_MATCH_1}) + set (RC_VERSION_MINOR ${CMAKE_MATCH_2}) + set (RC_VERSION_BUILD ${CMAKE_MATCH_3}) + + if (WIN32) + if (IS_EXE) + if (VERSIONING) + set (RC_VERSION_FILE "${name}${RC_VERSION_MAJOR}${CMAKE_EXECUTABLE_SUFFIX}" ) + else() + set (RC_VERSION_FILE "${name}${CMAKE_EXECUTABLE_SUFFIX}" ) + endif() + else() + if (VERSIONING) + set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${name}${RC_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) + else() + set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) + endif() + endif() + + configure_file( + ${add_resource_macro_internal_dir}/WindowsDLLVersion.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/version.rc + @ONLY + ) + + list(APPEND ${sources} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) + endif() + + set(OUTPUT_FILENAME "${name}") + if (VERSIONING) + set(OUTPUT_FILENAME "${name}${RC_VERSION_MAJOR}") + endif() + + if (IS_EXE) + message("add_executable(${target}) [${exe_options}]") + add_executable( + ${target} + ${exe_options} + ${${sources}} + ) + + set_target_properties( + ${target} + PROPERTIES + OUTPUT_NAME ${OUTPUT_FILENAME} + ) + set (OUTPUT_FILENAME "${OUTPUT_FILENAME}${CMAKE_EXECUTABLE_SUFFIX}" ) + else() + message("add_library(${target}) [${lib_options}]") + add_library(${target} + ${lib_options} + ${${sources}}) + + if (VERSIONING) + set_target_properties( + ${target} + PROPERTIES + VERSION ${version} + SOVERSION ${RC_VERSION_MAJOR} + ) + else() + set_target_properties(${target} PROPERTIES PREFIX "") + set_target_properties(${target} PROPERTIES NO_SONAME 1) + endif() + + set_target_properties( + ${target} + PROPERTIES + OUTPUT_NAME ${OUTPUT_FILENAME} + ) + set (OUTPUT_FILENAME "${CMAKE_SHARED_LIBRARY_PREFIX}${OUTPUT_FILENAME}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) + endif() + + + if (WITH_DEBUG_SYMBOLS AND MSVC AND (is_exe OR BUILD_SHARED_LIBS)) + message("add PDB for ${OUTPUT_FILENAME}") + set_target_properties( + ${target} + PROPERTIES + PDB_NAME ${OUTPUT_FILENAME} + ) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols) + endif() +endmacro() diff --git a/cmake/CommonConfigOptions.cmake b/cmake/CommonConfigOptions.cmake index e144bbfda..66924e85e 100644 --- a/cmake/CommonConfigOptions.cmake +++ b/cmake/CommonConfigOptions.cmake @@ -34,4 +34,4 @@ include(GNUInstallDirsWrapper) include(MSVCRuntime) include(ConfigureRPATH) include(ClangTidy) - +include(AddTargetWithResourceFile) diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index ce451c600..a5ce58ad8 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -80,6 +80,7 @@ endif() option(WITH_THIRD_PARTY "Build third-party components" OFF) option(WITH_CLIENT_INTERFACE "Build clients as a library with an interface" OFF) +CMAKE_DEPENDENT_OPTION(CLIENT_INTERFACE_SHARED "Build clients as a shared library with an interface" OFF "WITH_CLIENT_INTERFACE" OFF) option(WITH_SERVER_INTERFACE "Build servers as a library with an interface" ON) option(WITH_DEBUG_ALL "Print all debug messages." OFF) diff --git a/cmake/ConfigureRPATH.cmake b/cmake/ConfigureRPATH.cmake index 8c58314c4..284511f62 100644 --- a/cmake/ConfigureRPATH.cmake +++ b/cmake/ConfigureRPATH.cmake @@ -3,14 +3,14 @@ option(CMAKE_SKIP_BUILD_RPATH "skip build RPATH" OFF) option(CMAKE_BUILD_WITH_INSTALL_RPATH "build with install RPATH" OFF) option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "build with link RPATH" OFF) -if (BUILD_SHARED_LIBS) - option(CMAKE_MACOSX_RPATH "MacOSX RPATH" ON) -endif() - if (APPLE) + if (BUILD_SHARED_LIBS) + option(CMAKE_MACOSX_RPATH "MacOSX RPATH" ON) + endif() + file(RELATIVE_PATH FRAMEWORK_PATH ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_LIBDIR}) set(CFG_INSTALL_RPATH "@loader_path/${FRAMEWORK_PATH}") -else (APPLE) +elseif(NOT WIN32) if (NOT FREEBSD) option(WITH_ADD_PLUGIN_TO_RPATH "Add extension and plugin path to RPATH" OFF) if (WITH_ADD_PLUGIN_TO_RPATH) diff --git a/cmake/InstallFreeRDPMan.cmake b/cmake/InstallFreeRDPMan.cmake index ba0d8a8af..c333f6497 100644 --- a/cmake/InstallFreeRDPMan.cmake +++ b/cmake/InstallFreeRDPMan.cmake @@ -7,11 +7,27 @@ function(install_freerdp_man manpage section) endif() endfunction() -function(generate_and_install_freerdp_man_from_xml template manpage dependencies) +function(generate_and_install_freerdp_man_from_template name_base section api) if(WITH_MANPAGES) - find_program(XSLTPROC_EXECUTABLE NAMES xsltproc REQUIRED) - if (NOT DOCBOOKXSL_FOUND) - message(FATAL_ERROR "docbook xsl not found but required for manpage generation") + if (WITH_BINARY_VERSIONING) + set(manpage "${CMAKE_CURRENT_BINARY_DIR}/${name_base}${api}.${section}") + else() + set(manpage "${CMAKE_CURRENT_BINARY_DIR}/${name_base}.${section}") + endif() + configure_file(${name_base}.${section}.in ${manpage}) + install_freerdp_man(${manpage} ${section}) + endif() +endfunction() + +function(generate_and_install_freerdp_man_from_xml name_base section api dependencies) + if(WITH_MANPAGES) + set(template "${name_base}.${section}") + if (WITH_BINARY_VERSIONING) + set(MANPAGE_NAME "${name_base}${api}") + set(manpage "${name_base}${api}.${section}") + else() + set(MANPAGE_NAME "${name_base}") + set(manpage "${name_base}.${section}") endif() # We need the variable ${MAN_TODAY} to contain the current date in ISO @@ -34,8 +50,13 @@ function(generate_and_install_freerdp_man_from_xml template manpage dependencies endif() endforeach() + find_program(XSLTPROC_EXECUTABLE NAMES xsltproc REQUIRED) + if (NOT DOCBOOKXSL_FOUND) + message(FATAL_ERROR "docbook xsl not found but required for manpage generation") + endif() + add_custom_command( - OUTPUT ${manpage} + OUTPUT "${manpage}" COMMAND ${CMAKE_BINARY_DIR}/client/common/man/generate_argument_docbook COMMAND ${XSLTPROC_EXECUTABLE} --path "${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}" ${DOCBOOKXSL_DIR}/manpages/docbook.xsl ${manpage}.xml WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -50,6 +71,6 @@ function(generate_and_install_freerdp_man_from_xml template manpage dependencies DEPENDS ${manpage} ) - install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${manpage} 1) + install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${manpage} ${section}) endif() endfunction() diff --git a/libfreerdp/CMakeLists.txt b/libfreerdp/CMakeLists.txt index 0a7aae253..b897f2fbf 100644 --- a/libfreerdp/CMakeLists.txt +++ b/libfreerdp/CMakeLists.txt @@ -433,32 +433,10 @@ list(REMOVE_DUPLICATES LIBFREERDP_DEFINITIONS) list(REMOVE_DUPLICATES LIBFREERDP_INCLUDES) include_directories(${LIBFREERDP_INCLUDES}) -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${FREERDP_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) +AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" LIBFREERDP_SRCS) - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set (LIBFREERDP_SRCS ${LIBFREERDP_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_library(${MODULE_NAME} ${LIBFREERDP_SRCS}) add_definitions(${LIBFREERDP_DEFINITIONS}) -set_target_properties(${MODULE_NAME} PROPERTIES LINKER_LANGUAGE C) -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${FREERDP_VERSION_MAJOR}) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() - target_include_directories(${MODULE_NAME} INTERFACE $) target_link_libraries(${MODULE_NAME} PRIVATE ${LIBFREERDP_LIBS}) target_link_libraries(${MODULE_NAME} PUBLIC ${LIBFREERDP_PUB_LIBS}) @@ -467,11 +445,6 @@ install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT FreeRDPTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "FreeRDP/libfreerdp") include(pkg-config-install-prefix) diff --git a/rdtk/librdtk/CMakeLists.txt b/rdtk/librdtk/CMakeLists.txt index 03e0418f6..e872c2376 100644 --- a/rdtk/librdtk/CMakeLists.txt +++ b/rdtk/librdtk/CMakeLists.txt @@ -36,35 +36,13 @@ set(${MODULE_PREFIX}_SRCS rdtk_engine.c rdtk_engine.h) -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32) - set (RC_VERSION_MAJOR ${RDTK_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${RDTK_VERSION_MINOR}) - set (RC_VERSION_BUILD ${RDTK_VERSION_REVISION}) - set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${RDTK_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - list (APPEND ${MODULE_PREFIX}_SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +AddTargetWithResourceFile(${MODULE_NAME} FALSE "${RDTK_VERSION}" ${MODULE_PREFIX}_SRCS) list(APPEND ${MODULE_PREFIX}_LIBS winpr) target_include_directories(${MODULE_NAME} INTERFACE $) target_link_libraries(${MODULE_NAME} PRIVATE ${${MODULE_PREFIX}_LIBS}) -set_target_properties(${MODULE_NAME} PROPERTIES LINKER_LANGUAGE C) -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${RDTK_API_VERSION}) -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${RDTK_VERSION} SOVERSION ${RDTK_API_VERSION}) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "RdTk") if(BUILD_TESTING) @@ -76,9 +54,4 @@ if (NOT RDTK_FORCE_STATIC_BUILD) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - - if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) - endif() endif() diff --git a/rdtk/sample/CMakeLists.txt b/rdtk/sample/CMakeLists.txt index 1b4f025c0..05f44f8f1 100644 --- a/rdtk/sample/CMakeLists.txt +++ b/rdtk/sample/CMakeLists.txt @@ -25,10 +25,7 @@ include_directories(${X11_INCLUDE_DIR}) set(SRCS rdtk_x11.c) -add_executable(${MODULE_NAME} ${SRCS}) -if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${MODULE_NAME}${RDTK_API_VERSION}") -endif() +AddTargetWithResourceFile(${MODULE_NAME} TRUE "${RDTK_VERSION}" SRCS) set(LIBS rdtk) diff --git a/server/Sample/CMakeLists.txt b/server/Sample/CMakeLists.txt index e23f65c82..9a59d8bff 100644 --- a/server/Sample/CMakeLists.txt +++ b/server/Sample/CMakeLists.txt @@ -32,22 +32,6 @@ if (CHANNEL_AINPUT_SERVER) list(APPEND SRCS sf_ainput.c sf_ainput.h) endif() - # On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set ( SRCS ${SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - if (WITH_BINARY_VERSIONING) set(SAMPLE_RESOURCE_ROOT ${CMAKE_INSTALL_FULL_DATAROOTDIR}/FreeRDP${FREERDP_VERSION_MAJOR}/images) else() @@ -65,10 +49,7 @@ install(FILES ${SAMPLE_ICONS} DESTINATION ${SAMPLE_RESOURCE_ROOT}) # We need this in runtime path for TestConnect file(COPY test_icon.bmp DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -add_executable(${MODULE_NAME} ${SRCS}) -if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${MODULE_NAME}${FREERDP_API_VERSION}") -endif() +AddTargetWithResourceFile(${MODULE_NAME} TRUE "${FREERDP_VERSION}" SRCS) target_compile_definitions(${MODULE_NAME} PRIVATE @@ -79,8 +60,5 @@ list(APPEND LIBS winpr freerdp) target_link_libraries(${MODULE_NAME} ${LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) -if (WITH_DEBUG_SYMBOLS AND MSVC) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${MODULE_NAME}.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols) -endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Sample") diff --git a/server/Windows/CMakeLists.txt b/server/Windows/CMakeLists.txt index 2744b65d0..20f151811 100644 --- a/server/Windows/CMakeLists.txt +++ b/server/Windows/CMakeLists.txt @@ -61,37 +61,12 @@ if(CHANNEL_RDPSND AND WITH_RDPSND_DSOUND) ) endif() -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) -set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) -set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) if(WITH_SERVER_INTERFACE) - set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${FREERDP_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) -else() - set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" ) -endif() - -configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - -set (${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) - -if(WITH_SERVER_INTERFACE) - add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${FREERDP_API_VERSION}) - if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) - endif() + AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" ${MODULE_PREFIX}_SRCS) target_include_directories(${MODULE_NAME} INTERFACE $) else() - set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} cli/wfreerdp.c cli/wfreerdp.h) - add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) - if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${MODULE_NAME}${FREERDP_API_VERSION}") - endif() + list(APPEND ${MODULE_PREFIX}_SRCS cli/wfreerdp.c cli/wfreerdp.h) + AddTargetWithResourceFile(${MODULE_NAME} TRUE "${FREERDP_VERSION}" ${MODULE_PREFIX}_SRCS) endif() @@ -109,16 +84,8 @@ if(WITH_SERVER_INTERFACE) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - - if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS) - install(FILES ${PROJECT_BINARY_DIR}/${MODULE_NAME}${FREERDP_VERSION_MAJOR}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) - endif() else() install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) - - if (WITH_DEBUG_SYMBOLS AND MSVC) - install(FILES ${PROJECT_BINARY_DIR}/${MODULE_NAME}.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols) - endif() endif() if(WITH_SERVER_INTERFACE) diff --git a/server/Windows/cli/CMakeLists.txt b/server/Windows/cli/CMakeLists.txt index d3dc4477d..c362f66ab 100644 --- a/server/Windows/cli/CMakeLists.txt +++ b/server/Windows/cli/CMakeLists.txt @@ -25,29 +25,7 @@ set(${MODULE_PREFIX}_SRCS wfreerdp.c wfreerdp.h) -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) -set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) -set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) -set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" ) - -configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - -set (${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) - -add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) - -if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${OUTPUT_NAME}${FREERDP_API_VERSION}") - set_target_properties(${MODULE_NAME} PROPERTIES PDB_NAME "${OUTPUT_NAME}${FREERDP_API_VERSION}${CMAKE_EXECUTABLE_SUFFIX}") -else() - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${OUTPUT_NAME}") - set_target_properties(${MODULE_NAME} PROPERTIES PDB_NAME "${OUTPUT_NAME}${CMAKE_EXECUTABLE_SUFFIX}") -endif() +AddTargetWithResourceFile(${MODULE_NAME} TRUE "${FREERDP_VERSION}" ${MODULE_PREFIX}_SRCS) set(${MODULE_PREFIX}_LIBS wfreerdp-server) @@ -55,8 +33,4 @@ target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) -if (WITH_DEBUG_SYMBOLS AND MSVC) - install(FILES ${PROJECT_BINARY_DIR}/${OUTPUT_NAME}.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Windows") diff --git a/server/common/CMakeLists.txt b/server/common/CMakeLists.txt index 5552688c3..6795ba9be 100644 --- a/server/common/CMakeLists.txt +++ b/server/common/CMakeLists.txt @@ -36,29 +36,7 @@ if(MSVC) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS}) endif() - -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${FREERDP_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set (${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${FREERDP_API_VERSION}) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() +AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" ${MODULE_PREFIX}_SRCS) target_include_directories(${MODULE_NAME} INTERFACE $) target_link_libraries(${MODULE_NAME} PRIVATE ${FREERDP_CHANNELS_SERVER_LIBS}) @@ -69,9 +47,4 @@ install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT FreeRDP-ServerTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Common") diff --git a/server/proxy/CMakeLists.txt b/server/proxy/CMakeLists.txt index 4693b1722..8a262ddd3 100644 --- a/server/proxy/CMakeLists.txt +++ b/server/proxy/CMakeLists.txt @@ -47,29 +47,7 @@ set(PROXY_APP_SRCS freerdp_proxy.c) option(WITH_PROXY_EMULATE_SMARTCARD "Compile proxy smartcard emulation" OFF) add_subdirectory("channels") -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set ( ${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) - list(APPEND PROXY_APP_SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${FREERDP_API_VERSION}) - -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() +AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" ${MODULE_PREFIX}_SRCS) set(PRIVATE_LIBS freerdp-client @@ -89,11 +67,6 @@ install(TARGETS ${MODULE_NAME} COMPONENT server EXPORT FreeRDP-ProxyTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Proxy") # pkg-config diff --git a/server/proxy/cli/CMakeLists.txt b/server/proxy/cli/CMakeLists.txt index 1416b4a86..a532f90a9 100644 --- a/server/proxy/cli/CMakeLists.txt +++ b/server/proxy/cli/CMakeLists.txt @@ -18,43 +18,12 @@ set(PROXY_APP_SRCS freerdp_proxy.c) -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - list(APPEND PROXY_APP_SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - set(APP_NAME "freerdp-proxy") -add_executable(${APP_NAME} - ${PROXY_APP_SRCS} -) - -set(MANPAGE_NAME ${APP_NAME}.1) -if (WITH_BINARY_VERSIONING) - set_target_properties(${APP_NAME} - PROPERTIES - OUTPUT_NAME "${APP_NAME}${FREERDP_API_VERSION}" - ) - set(MANPAGE_NAME ${APP_NAME}${FREERDP_API_VERSION}.1) -endif() +AddTargetWithResourceFile(${APP_NAME} TRUE "${FREERDP_VERSION}" PROXY_APP_SRCS) target_link_libraries(${APP_NAME} ${MODULE_NAME}) install(TARGETS ${APP_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) -if (WITH_DEBUG_SYMBOLS AND MSVC) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${APP_NAME}.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols) -endif() set_property(TARGET ${APP_NAME} PROPERTY FOLDER "Server/proxy") -configure_file(${APP_NAME}.1.in ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}) -install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME} 1) +generate_and_install_freerdp_man_from_template(${APP_NAME} "1" "${FREERDP_API_VERSION}") diff --git a/server/proxy/modules/bitmap-filter/CMakeLists.txt b/server/proxy/modules/bitmap-filter/CMakeLists.txt index d2cc03bd0..e51853fbd 100644 --- a/server/proxy/modules/bitmap-filter/CMakeLists.txt +++ b/server/proxy/modules/bitmap-filter/CMakeLists.txt @@ -48,13 +48,11 @@ include(CommonConfigOptions) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_library(${PROJECT_NAME} SHARED +set(SRCS bitmap-filter.cpp ) +AddTargetWithResourceFile(${PROJECT_NAME} FALSE "${PROJECT_VERSION}" SRCS FALSE) target_link_libraries(${PROJECT_NAME} winpr freerdp) -set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") -set_target_properties(${PROJECT_NAME} PROPERTIES NO_SONAME 1) - install(TARGETS ${PROJECT_NAME} DESTINATION ${FREERDP_PROXY_PLUGINDIR}) diff --git a/server/proxy/modules/demo/CMakeLists.txt b/server/proxy/modules/demo/CMakeLists.txt index bdd85a337..ba1382bad 100644 --- a/server/proxy/modules/demo/CMakeLists.txt +++ b/server/proxy/modules/demo/CMakeLists.txt @@ -41,13 +41,11 @@ include(CommonConfigOptions) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_library(${PROJECT_NAME} SHARED +set(SRCS demo.cpp ) +AddTargetWithResourceFile(${PROJECT_NAME} FALSE "${PROJECT_VERSION}" SRCS FALSE) target_link_libraries(${PROJECT_NAME} winpr) -set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") -set_target_properties(${PROJECT_NAME} PROPERTIES NO_SONAME 1) - install(TARGETS ${PROJECT_NAME} DESTINATION ${FREERDP_PROXY_PLUGINDIR}) diff --git a/server/proxy/modules/dyn-channel-dump/CMakeLists.txt b/server/proxy/modules/dyn-channel-dump/CMakeLists.txt index dc0fc535b..dff349ca1 100644 --- a/server/proxy/modules/dyn-channel-dump/CMakeLists.txt +++ b/server/proxy/modules/dyn-channel-dump/CMakeLists.txt @@ -40,9 +40,10 @@ include(CommonConfigOptions) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_library(${PROJECT_NAME} SHARED +set(SRCS dyn-channel-dump.cpp ) +AddTargetWithResourceFile(${PROJECT_NAME} FALSE "${PROJECT_VERSION}" SRCS FALSE) target_link_libraries(${PROJECT_NAME} PRIVATE winpr @@ -52,7 +53,4 @@ target_link_libraries(${PROJECT_NAME} PRIVATE freerdp-server-proxy ) -set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") -set_target_properties(${PROJECT_NAME} PROPERTIES NO_SONAME 1) - install(TARGETS ${PROJECT_NAME} DESTINATION ${FREERDP_PROXY_PLUGINDIR}) diff --git a/server/shadow/CMakeLists.txt b/server/shadow/CMakeLists.txt index 72adcca76..159b6b6f4 100644 --- a/server/shadow/CMakeLists.txt +++ b/server/shadow/CMakeLists.txt @@ -64,24 +64,7 @@ else() include_directories(${PROJECT_BINARY_DIR}/rdtk/include) endif() -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_PATCH 0) - set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${FREERDP_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - -list (APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_library(${MODULE_NAME} ${SRCS}) +AddTargetWithResourceFile(${MODULE_NAME} "FALSE" "${FREERDP_VERSION}" SRCS) list(APPEND LIBS freerdp @@ -94,21 +77,11 @@ list(APPEND LIBS target_include_directories(${MODULE_NAME} INTERFACE $) target_link_libraries(${MODULE_NAME} PRIVATE ${LIBS}) -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${FREERDP_VERSION_MAJOR}) -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() - install(TARGETS ${MODULE_NAME} COMPONENT server EXPORT FreeRDP-ShadowTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -if (WITH_DEBUG_SYMBOLS AND MSVC) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${PROJECT_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/shadow") # subsystem library @@ -126,21 +99,7 @@ elseif(APPLE AND NOT IOS) add_subdirectory(Mac) endif() -if (WIN32) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set ( SRCS ${SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_library(${MODULE_NAME} ${SRCS}) +AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" SRCS) list(APPEND LIBS freerdp-shadow-subsystem-impl @@ -152,11 +111,6 @@ list(APPEND LIBS target_include_directories(${MODULE_NAME} INTERFACE $) target_link_libraries(${MODULE_NAME} PRIVATE ${LIBS}) -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${FREERDP_API_VERSION}) -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION}) -endif() - if (NOT BUILD_SHARED_LIBS) install(TARGETS freerdp-shadow-subsystem-impl DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -169,12 +123,6 @@ install(TARGETS ${MODULE_NAME} COMPONENT server EXPORT FreeRDP-ShadowTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -if (WITH_DEBUG_SYMBOLS AND MSVC) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${PROJECT_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT symbols) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/shadow") # command-line executable @@ -184,46 +132,20 @@ set(MODULE_NAME "freerdp-shadow-cli") set(SRCS shadow.c) -# On windows create dll version information. -# Vendor, product and year are already set in top level CMakeLists.txt -if (WIN32) - set (RC_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) - set (RC_VERSION_MINOR ${FREERDP_VERSION_MINOR}) - set (RC_VERSION_BUILD ${FREERDP_VERSION_REVISION}) - set (RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set ( SRCS ${SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_executable(${MODULE_NAME} ${SRCS}) - -set(MANPAGE_NAME "${MODULE_NAME}") -if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${MODULE_NAME}${FREERDP_API_VERSION}") - set(MANPAGE_NAME "${MODULE_NAME}${FREERDP_API_VERSION}") -endif() +AddTargetWithResourceFile(${MODULE_NAME} TRUE "${FREERDP_VERSION}" SRCS) list(APPEND LIBS freerdp-shadow-subsystem freerdp-shadow freerdp winpr) target_link_libraries(${MODULE_NAME} PRIVATE ${LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) -if (WITH_DEBUG_SYMBOLS AND MSVC) - install(FILES ${PROJECT_BINARY_DIR}/${MODULE_NAME}.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT symbols) -endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/shadow") include(pkg-config-install-prefix) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/freerdp-shadow.pc.in ${CMAKE_CURRENT_BINARY_DIR}/freerdp-shadow${FREERDP_VERSION_MAJOR}.pc @ONLY) -configure_file(freerdp-shadow-cli.1.in ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.1) -install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.1 1) + +generate_and_install_freerdp_man_from_template(${MODULE_NAME} "1" "${FREERDP_API_VERSION}") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freerdp-shadow${FREERDP_VERSION_MAJOR}.pc DESTINATION ${PKG_CONFIG_PC_INSTALL_DIR}) diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index 6d6f4d818..0df05ab9a 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -341,12 +341,7 @@ endif() add_subdirectory(include) -set(MANPAGE_NAME wlog) -if (WITH_BINARY_VERSIONING) - set(MANPAGE_NAME wlog${WINPR_API_VERSION}) -endif() -configure_file(wlog.7.in ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.7 @ONLY) -install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.7 7) +generate_and_install_freerdp_man_from_template("wlog" "7" "${WINPR_API_VERSION}") # Exporting export(PACKAGE winpr) diff --git a/winpr/libwinpr/CMakeLists.txt b/winpr/libwinpr/CMakeLists.txt index f1266f3fd..1c85d37f5 100644 --- a/winpr/libwinpr/CMakeLists.txt +++ b/winpr/libwinpr/CMakeLists.txt @@ -159,32 +159,11 @@ list(REMOVE_DUPLICATES WINPR_LINK_OPTIONS) list(REMOVE_DUPLICATES WINPR_LINK_DIRS) list(REMOVE_DUPLICATES WINPR_INCLUDES) -# 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}) - set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${WINPR_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) +AddTargetWithResourceFile(${MODULE_NAME} FALSE "${WINPR_VERSION}" WINPR_SRCS) - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set (WINPR_SRCS ${WINPR_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) - winpr_library_add_public("shlwapi") -endif() - -add_library(${MODULE_NAME} ${WINPR_SRCS}) if (APPLE) set_target_properties(${MODULE_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION FALSE) endif() -set_target_properties(${MODULE_NAME} PROPERTIES LINKER_LANGUAGE C) -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${WINPR_API_VERSION}) -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION} SOVERSION ${WINPR_API_VERSION}) -endif() if (NOT BUILD_SHARED_LIBS) set(LINK_OPTS_MODE PUBLIC) @@ -204,8 +183,4 @@ install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT WinPRTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) -endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/libwinpr") diff --git a/winpr/libwinpr/path/CMakeLists.txt b/winpr/libwinpr/path/CMakeLists.txt index 1e4ed9201..201279368 100644 --- a/winpr/libwinpr/path/CMakeLists.txt +++ b/winpr/libwinpr/path/CMakeLists.txt @@ -17,6 +17,10 @@ winpr_module_add(path.c shell.c) +if (MSVC) + winpr_library_add_public(shlwapi) +endif() + if (IOS) winpr_module_add(shell_ios.m) endif (IOS) diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index 4380a9b6d..a1e7b4e77 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -670,12 +670,6 @@ fail: return ret; } -#else - -#ifdef _MSC_VER -#pragma comment(lib, "shlwapi.lib") -#endif - #endif BOOL winpr_MoveFile(LPCSTR lpExistingFileName, LPCSTR lpNewFileName) diff --git a/winpr/tools/CMakeLists.txt b/winpr/tools/CMakeLists.txt index cc4eabb9f..d7446bc3a 100644 --- a/winpr/tools/CMakeLists.txt +++ b/winpr/tools/CMakeLists.txt @@ -85,28 +85,7 @@ list(REMOVE_DUPLICATES WINPR_TOOLS_DEFINITIONS) list(REMOVE_DUPLICATES WINPR_TOOLS_INCLUDES) include_directories(${WINPR_TOOLS_INCLUDES}) -# 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}) - set (RC_VERSION_FILE "${CMAKE_SHARED_LIBRARY_PREFIX}${MODULE_NAME}${WINPR_TOOLS_API_VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}" ) - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set (WINPR_TOOLS_SRCS ${WINPR_TOOLS_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_library(${MODULE_NAME} ${WINPR_TOOLS_SRCS}) -set_target_properties(${MODULE_NAME} PROPERTIES LINKER_LANGUAGE C) -set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${WINPR_TOOLS_API_VERSION}) -if (WITH_LIBRARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_TOOLS_VERSION} SOVERSION ${WINPR_TOOLS_API_VERSION}) -endif() +AddTargetWithResourceFile(${MODULE_NAME} FALSE "${WINPR_VERSION}" WINPR_TOOLS_SRCS) add_definitions(${WINPR_DEFINITIONS}) target_include_directories(${MODULE_NAME} INTERFACE $) @@ -117,10 +96,6 @@ install(TARGETS ${MODULE_NAME} COMPONENT libraries EXPORT WinPR-toolsTargets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -if (WITH_DEBUG_SYMBOLS AND MSVC AND BUILD_SHARED_LIBS) - get_target_property(OUTPUT_FILENAME ${MODULE_NAME} OUTPUT_NAME) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${OUTPUT_FILENAME}.pdb DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT symbols) -endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Tools") # Add all command line utilities diff --git a/winpr/tools/hash-cli/CMakeLists.txt b/winpr/tools/hash-cli/CMakeLists.txt index 8f583d363..8eb9e6692 100644 --- a/winpr/tools/hash-cli/CMakeLists.txt +++ b/winpr/tools/hash-cli/CMakeLists.txt @@ -21,39 +21,13 @@ set(MODULE_PREFIX "WINPR_TOOLS_HASH") set(${MODULE_PREFIX}_SRCS hash.c) -# 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}) - set(RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}") - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +AddTargetWithResourceFile(${MODULE_NAME} TRUE "${WINPR_VERSION}" ${MODULE_PREFIX}_SRCS) set(${MODULE_PREFIX}_LIBS winpr) -set(MANPAGE_NAME "${MODULE_NAME}") -if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "${MODULE_NAME}${WINPR_API_VERSION}") - set(MANPAGE_NAME "${MODULE_NAME}${WINPR_API_VERSION}") -endif() target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT tools EXPORT WinPRTargets) -if (WITH_DEBUG_SYMBOLS AND MSVC) - install(FILES ${PROJECT_BINARY_DIR}/${MODULE_NAME}.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols) -endif() - set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Tools") -configure_file(winpr-hash.1.in ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.1) -install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.1 1) +generate_and_install_freerdp_man_from_template(${MODULE_NAME} "1" "${WINPR_API_VERSION}") diff --git a/winpr/tools/makecert-cli/CMakeLists.txt b/winpr/tools/makecert-cli/CMakeLists.txt index e92d6f2e3..fe9c6f735 100644 --- a/winpr/tools/makecert-cli/CMakeLists.txt +++ b/winpr/tools/makecert-cli/CMakeLists.txt @@ -22,42 +22,14 @@ set(MODULE_PREFIX "WINPR_MAKECERT") set(${MODULE_PREFIX}_SRCS main.c) -# 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}) - set(RC_VERSION_FILE "${MODULE_NAME}${CMAKE_EXECUTABLE_SUFFIX}") - - configure_file( - ${PROJECT_SOURCE_DIR}/cmake/WindowsDLLVersion.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/version.rc - @ONLY) - - set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/version.rc) -endif() - -add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +AddTargetWithResourceFile(${MODULE_NAME} TRUE "${WINPR_VERSION}" ${MODULE_PREFIX}_SRCS) set(${MODULE_PREFIX}_LIBS winpr-tools) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS} winpr) -set(MANPAGE_NAME ${MODULE_NAME}) -if (WITH_BINARY_VERSIONING) - set_target_properties(${MODULE_NAME} - PROPERTIES - OUTPUT_NAME "${MODULE_NAME}${WINPR_API_VERSION}" - ) - set(MANPAGE_NAME ${MODULE_NAME}${WINPR_API_VERSION}) -endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Tools") install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT tools EXPORT WinPRTargets) -if (WITH_DEBUG_SYMBOLS AND MSVC) - install(FILES ${CMAKE_PDB_BINARY_DIR}/${MODULE_NAME}.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT symbols) -endif() -configure_file(winpr-makecert.1.in ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.1) -install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE_NAME}.1 1) +generate_and_install_freerdp_man_from_template(${MODULE_NAME} "1" "${WINPR_API_VERSION}") diff --git a/winpr/tools/makecert/CMakeLists.txt b/winpr/tools/makecert/CMakeLists.txt index a41cccd3e..de3ef9235 100644 --- a/winpr/tools/makecert/CMakeLists.txt +++ b/winpr/tools/makecert/CMakeLists.txt @@ -32,13 +32,7 @@ endif() winpr_tools_module_add(${${MODULE_PREFIX}_SRCS}) if(OPENSSL_FOUND) - if(WIN32) - list(APPEND ${MODULE_PREFIX}_LIBS ${OPENSSL_LIBRARIES}) - else() - # if ${OPENSSL_LIBRARIES} libssl and libcrypto is linked - # therefor explicitly link against libcrypto - list(APPEND ${MODULE_PREFIX}_LIBS ${OPENSSL_CRYPTO_LIBRARIES}) - endif() + list(APPEND ${MODULE_PREFIX}_LIBS ${OPENSSL_LIBRARIES}) endif() if(MBEDTLS_FOUND)