-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cpp/Chat cmake files #262
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
project(chat_client CXX) | ||
|
||
include(../../cmake/common.cmake) | ||
|
||
set(common_sources ChatUtils.cpp ChatUtils.h Chat.ice) | ||
|
||
add_executable(chatgl2client Client.cpp ChatSession.ice ${common_sources}) | ||
slice2cpp_generate(chatgl2client) | ||
target_link_libraries(chatgl2client Ice::Ice Ice::Glacier2) | ||
|
||
add_executable(chatpollclient PollingClient.cpp PollingChat.ice ${common_sources}) | ||
slice2cpp_generate(chatpollclient) | ||
target_link_libraries(chatpollclient Ice::Ice) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,9 @@ | |
|
||
#pragma once | ||
|
||
#include "Chat.ice" | ||
|
||
#include <Ice/BuiltinSequences.ice> | ||
#include <Chat.ice> | ||
|
||
/** | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
project(chat_client CXX) | ||
|
||
include(../../cmake/common.cmake) | ||
|
||
add_executable(chatserver | ||
ChatRoom.cpp ChatRoom.h | ||
ChatServer.cpp | ||
ChatSessionI.cpp ChatSessionI.h | ||
ChatSessionManagerI.cpp ChatSessionManagerI.h | ||
Chat.ice ChatSession.ice | ||
|
||
PollingChatSessionFactoryI.cpp PollingChatSessionFactoryI.h | ||
PollingChatSessionI.cpp PollingChatSessionI.h | ||
PollingChat.ice | ||
|
||
ChatUtils.cpp ChatUtils.h | ||
) | ||
slice2cpp_generate(chatserver) | ||
target_link_libraries(chatserver Ice::Ice Ice::Glacier2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright (c) ZeroC, Inc. | ||
|
||
#include <ChatRoom.h> | ||
#include "ChatRoom.h" | ||
|
||
using namespace std; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
|
||
#pragma once | ||
|
||
#include "Chat.ice" | ||
|
||
#include <Ice/BuiltinSequences.ice> | ||
#include <Chat.ice> | ||
|
||
|
||
/** | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
if (NOT Ice_HOME) | ||
if (DEFINED ENV{ICE_HOME}) | ||
set(Ice_HOME $ENV{ICE_HOME} CACHE PATH "Path to the Ice installation directory") | ||
else() | ||
message(FATAL_ERROR "Ice_HOME not set") | ||
endif() | ||
endif() | ||
|
||
if (NOT EXISTS ${Ice_HOME}) | ||
message(FATAL_ERROR "The specified Ice_HOME directory does not exist: ${Ice_HOME}") | ||
endif() | ||
|
||
find_program(Ice_SLICE2CPP_EXECUTABLE slice2cpp HINTS ${Ice_HOME}/cpp/bin PATH_SUFFIXES x64/Release x64/Debug) | ||
|
||
if(NOT DEFINED Ice_SLICE_DIR AND EXISTS ${Ice_HOME}/slice) | ||
set(Ice_SLICE_DIR ${Ice_HOME}/slice CACHE PATH "Path to the Ice Slice files directory") | ||
endif() | ||
|
||
# This is the only version we support for the demos right now | ||
set(Ice_VERSION "3.8.0-alpha.0" CACHE STRING "Ice version") | ||
set(Ice_DLL_VERSION "38a0" CACHE STRING "Ice DLL version") | ||
|
||
find_path(Ice_INCLUDE_DIR NAMES Ice/Ice.h HINTS ${Ice_HOME}/cpp/include) | ||
|
||
find_library(Ice_LIBRARY NAMES Ice Ice${Ice_DLL_VERSION} HINTS ${Ice_HOME}/cpp/lib/ PATH_SUFFIXES x64/Release) | ||
|
||
if (Ice_FIND_COMPONENTS) | ||
foreach(component IN LISTS Ice_FIND_COMPONENTS) | ||
string(TOUPPER "${component}" component_upcase) | ||
find_library(Ice_${component_upcase}_LIBRARY NAMES ${component} ${component}${Ice_DLL_VERSION} HINTS ${Ice_HOME}/cpp/lib/ PATH_SUFFIXES x64/Release ) | ||
endforeach() | ||
endif() | ||
|
||
find_package_handle_standard_args(Ice | ||
REQUIRED_VARS Ice_SLICE2CPP_EXECUTABLE | ||
Ice_INCLUDE_DIR | ||
Ice_LIBRARY | ||
Ice_SLICE_DIR | ||
VERSION_VAR Ice_VERSION) | ||
|
||
if(Ice_FOUND) | ||
# set(Ice_LIBRARIES ${Ice_LIBRARY}) | ||
if(WIN32) | ||
set(Ice_INCLUDE_DIRS ${Ice_INCLUDE_DIR} ${Ice_HOME}/cpp/include/generated ${Ice_HOME}/cpp/include/generated/x64/Release) | ||
else() | ||
set(Ice_INCLUDE_DIRS ${Ice_INCLUDE_DIR} ${Ice_HOME}/cpp/include/generated) | ||
endif() | ||
|
||
add_library(Ice::Ice UNKNOWN IMPORTED) | ||
# set_target_properties(Ice::Ice PROPERTIES IMPORTED_IMPLIB ${Ice_LIBRARY}) | ||
set_target_properties(Ice::Ice PROPERTIES | ||
IMPORTED_LOCATION ${Ice_LIBRARY} | ||
INTERFACE_INCLUDE_DIRECTORIES "${Ice_INCLUDE_DIRS}" | ||
) | ||
|
||
if (Ice_FIND_COMPONENTS) | ||
foreach(component IN LISTS Ice_FIND_COMPONENTS) | ||
string(TOUPPER "${component}" component_upcase) | ||
add_library(Ice::${component} UNKNOWN IMPORTED) | ||
set_target_properties(Ice::${component} PROPERTIES | ||
IMPORTED_LOCATION ${Ice_${component_upcase}_LIBRARY} | ||
INTERFACE_INCLUDE_DIRECTORIES "${Ice_INCLUDE_DIRS}" | ||
) | ||
endforeach() | ||
endif() | ||
endif() | ||
|
||
# Function to generate C++ source files from Slice (.ice) files for a target using slice2cpp | ||
# The target must have the Slice files in its sources | ||
# The generated files are added to the target sources | ||
# Usage: | ||
# add_executable(a_target source1.cpp source2.ice source3.ice) | ||
# slice2cpp_generate(a_target) | ||
function(slice2cpp_generate target) | ||
|
||
# Get the list of source files for the target | ||
get_target_property(sources ${target} SOURCES) | ||
|
||
# Create a directory to store the generated files | ||
set(output_dir ${CMAKE_CURRENT_BINARY_DIR}/generated/${target}) | ||
make_directory(${output_dir}) | ||
|
||
# Add the generated headers files to the target include directories | ||
target_include_directories(${target} PRIVATE ${output_dir}) | ||
|
||
# Process each Slice (.ice) file in the source list | ||
# 1. Run the slice2cpp command to generate the header and source files | ||
# 2. Add the generated files to the target sources | ||
foreach(file IN LISTS sources) | ||
if(file MATCHES "\\.ice$") | ||
|
||
get_filename_component(slice_file_name ${file} NAME_WE) | ||
get_filename_component(slice_file_path ${file} ABSOLUTE) | ||
set(output_files ${output_dir}/${slice_file_name}.h ${output_dir}/${slice_file_name}.cpp) | ||
|
||
add_custom_command( | ||
OUTPUT ${output_files} | ||
COMMAND ${Ice_SLICE2CPP_EXECUTABLE} -I${Ice_SLICE_DIR} ${slice_file_path} --output-dir ${output_dir} | ||
DEPENDS ${slice_file_path} | ||
COMMENT "${Ice_SLICE2CPP_EXECUTABLE} ${file} -> ${slice_file_name}.h ${slice_file_name}.cpp" | ||
) | ||
|
||
target_sources(${target} PRIVATE ${output_files}) | ||
|
||
endif() | ||
endforeach() | ||
endfunction() | ||
|
||
if(Ice_DEBUG) | ||
message(STATUS "Ice_VERSION: ${Ice_VERSION}") | ||
message(STATUS "Ice_HOME: ${Ice_HOME}") | ||
message(STATUS "Ice_INCLUDE_DIR: ${Ice_INCLUDE_DIR}") | ||
message(STATUS "Ice_INCLUDE_DIRS: ${Ice_INCLUDE_DIRS}") | ||
message(STATUS "Ice_SLICE_DIR directory: ${Ice_SLICE_DIR}") | ||
message(STATUS "Ice_LIBRARY: ${Ice_LIBRARY}") | ||
endif() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add Win32/Release Win32/Debug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Win32/x64 with cmake is generally figured out from the target os. See https://cmake.org/cmake/help/latest/variable/CMAKE_SIZEOF_VOID_P.html
I know we support Win32 builds with Ice, but I don't really see it being very useful and having to have some extra config to handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can still want to use Win32 binaries in x64 platforms, we assume nobody runs a Win32 native platform this days. Same for our x86 linux builds. Anyways this is something we can figure out later.