diff --git a/CMakeLists.txt b/CMakeLists.txt index 78ba4ae0e..e1e369aff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,9 @@ endif() # Compiler-specific flags if(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "i686") - if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686") endif() endif() @@ -151,9 +153,6 @@ if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") endif() - if(${CMAKE_VERSION} VERSION_LESS 2.8.9) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - endif() if(WITH_SSE2) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2") endif() diff --git a/client/X11/CMakeLists.txt b/client/X11/CMakeLists.txt index 2f833ed9d..96f4ec419 100644 --- a/client/X11/CMakeLists.txt +++ b/client/X11/CMakeLists.txt @@ -53,6 +53,7 @@ if(WITH_CLIENT_INTERFACE) else() set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} cli/xfreerdp.c cli/xfreerdp.h) add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp") endif() set(${MODULE_PREFIX}_LIBS @@ -146,7 +147,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHI target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) if(WITH_IPP) - target_link_libraries(xfreerdp ${IPP_LIBRARY_LIST}) + target_link_libraries(${MODULE_NAME} ${IPP_LIBRARY_LIST}) endif() if(WITH_CLIENT_INTERFACE) diff --git a/client/X11/cli/CMakeLists.txt b/client/X11/cli/CMakeLists.txt index 0abac9e69..2beef85b9 100644 --- a/client/X11/cli/CMakeLists.txt +++ b/client/X11/cli/CMakeLists.txt @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -set(MODULE_NAME "xfreerdp") +set(MODULE_NAME "xfreerdp-cli") set(MODULE_PREFIX "FREERDP_CLIENT_X11") include_directories(..) @@ -24,6 +24,7 @@ set(${MODULE_PREFIX}_SRCS xfreerdp.c) add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp") set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} xfreerdp-client) diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index 1aa0f94cf..2128d8f31 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -16,7 +16,7 @@ # limitations under the License. set(MODULE_NAME "xfreerdp-server") -set(MODULE_PREFIX "FREERDP_SERVER_X11") +set(MODULE_PREFIX "FREERDP_SERVER_X11_CONTROL") include_directories(${X11_INCLUDE_DIRS}) include_directories("../../winpr/tools/makecert") @@ -30,10 +30,20 @@ set(${MODULE_PREFIX}_SRCS xf_encode.h xf_interface.c xf_interface.h - xfreerdp.c xfreerdp.h) -add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +if(WITH_SERVER_INTERFACE) + if(SERVER_INTERFACE_SHARED) + add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS}) + else() + add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + endif() + set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION} PREFIX "lib") +else() + set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} cli/xfreerdp.c) + add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) + set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp-server") +endif() set(XEXT_FEATURE_TYPE "RECOMMENDED") set(XEXT_FEATURE_PURPOSE "X11 extension") @@ -106,7 +116,13 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-makecert-tool) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) -install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) + +if(WITH_SERVER_INTERFACE) + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) + add_subdirectory(cli) +else() + install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) +endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/X11") diff --git a/server/X11/cli/CMakeLists.txt b/server/X11/cli/CMakeLists.txt new file mode 100644 index 000000000..9d5dd037d --- /dev/null +++ b/server/X11/cli/CMakeLists.txt @@ -0,0 +1,36 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP X11 cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# 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. + +set(MODULE_NAME "xfreerdp-server-cli") +set(MODULE_PREFIX "FREERDP_SERVER_X11") + +include_directories(..) + +set(${MODULE_PREFIX}_SRCS + xfreerdp.c) + +add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) +set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME "xfreerdp-server") + +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} xfreerdp-server) + +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + +install(TARGETS ${MODULE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/X11") + diff --git a/server/X11/cli/xfreerdp-server b/server/X11/cli/xfreerdp-server new file mode 100755 index 000000000..9e837526b Binary files /dev/null and b/server/X11/cli/xfreerdp-server differ diff --git a/server/X11/xfreerdp.c b/server/X11/cli/xfreerdp.c similarity index 86% rename from server/X11/xfreerdp.c rename to server/X11/cli/xfreerdp.c index 3f952f1c6..bd3b27729 100644 --- a/server/X11/xfreerdp.c +++ b/server/X11/cli/xfreerdp.c @@ -21,11 +21,11 @@ #include "config.h" #endif -#include "xf_peer.h" -#include "xfreerdp.h" +#include "xf_interface.h" int main(int argc, char* argv[]) { + HANDLE thread; xfServer* server; DWORD dwExitCode; @@ -38,9 +38,11 @@ int main(int argc, char* argv[]) freerdp_server_start(server); - WaitForSingleObject(server->thread, INFINITE); + thread = freerdp_server_get_thread(server); - GetExitCodeThread(server->thread, &dwExitCode); + WaitForSingleObject(thread, INFINITE); + + GetExitCodeThread(thread, &dwExitCode); freerdp_server_free(server); diff --git a/server/X11/xf_interface.c b/server/X11/xf_interface.c index 2d70b3c1c..1c93b5e4e 100644 --- a/server/X11/xf_interface.c +++ b/server/X11/xf_interface.c @@ -117,7 +117,7 @@ int freerdp_server_start(xfServer* server) { if (server->listener->Open(server->listener, NULL, 3389)) { - server->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_thread, (void*) server, 0, NULL); + server->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) xf_server_thread, (void*) server, 0, NULL); } return 0; @@ -128,6 +128,11 @@ int freerdp_server_stop(xfServer* server) return 0; } +HANDLE freerdp_server_get_thread(xfServer* server) +{ + return server->thread; +} + xfServer* freerdp_server_new(int argc, char** argv) { xfServer* server; diff --git a/server/X11/xf_interface.h b/server/X11/xf_interface.h index 1fd07e47f..f62d36450 100644 --- a/server/X11/xf_interface.h +++ b/server/X11/xf_interface.h @@ -20,6 +20,8 @@ #ifndef XFREERDP_SERVER_INTERFACE_H #define XFREERDP_SERVER_INTERFACE_H +#include + #include #include @@ -40,6 +42,8 @@ FREERDP_API int freerdp_server_global_uninit(); FREERDP_API int freerdp_server_start(xfServer* server); FREERDP_API int freerdp_server_stop(xfServer* server); +FREERDP_API HANDLE freerdp_server_get_thread(xfServer* server); + FREERDP_API xfServer* freerdp_server_new(int argc, char** argv); FREERDP_API void freerdp_server_free(xfServer* server);