Skip to content
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 example for using the SigC++ library #556

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions examples/libsigcplusplus/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(CPMLibSigCppExample)

# ---- Dependencies ----

include(../../cmake/CPM.cmake)

CPMAddPackage("gh:libsigcplusplus/libsigcplusplus#3.6.0")
if(libsigcplusplus_ADDED)
set(SIGCPP_INCLUDE_DIRS ${libsigcplusplus_SOURCE_DIR} ${CPM_PACKAGE_libsigcplusplus_BINARY_DIR} )
set(SIGCPP_LIBRARY sigc-3.0)
endif()

# ---- Create binary ----

add_executable(CPMLibSigCppExample main.cpp)
target_include_directories(CPMLibSigCppExample PUBLIC ${SIGCPP_INCLUDE_DIRS})
target_link_libraries(CPMLibSigCppExample ${SIGCPP_LIBRARY})
target_compile_features(CPMLibSigCppExample PRIVATE cxx_std_17)
18 changes: 18 additions & 0 deletions examples/libsigcplusplus/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <sigc++/sigc++.h>
#include <iostream>

void example_callback() {
std::cout << "Hello World" << std::endl;
}

sigc::signal<void(void)> signal_say_hi;

int main() {
// Register callback
signal_say_hi.connect(sigc::ptr_fun(&example_callback));

// Emit signal, so that callback gets called
signal_say_hi.emit();

return 0;
}
Loading