diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..42c87e9f37549d58e165a71e2eb1819aa38d04a4 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 3.18) + +project(CuteProject VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + + +set(MY_TARGET "cybersolution") + +if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set(CMAKE_FIND_LIBRARY_PREFIXES "lib" ${CMAKE_FIND_LIBRARY_PREFIXES}) +endif() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -static-libgcc -static-libstdc++") + +aux_source_directory(src SOURCES) + +add_executable(${MY_TARGET} + lib/main.cpp + ${SOURCES} +) + +target_include_directories(${MY_TARGET} PRIVATE + lib +) + +target_link_directories(${MY_TARGET} PRIVATE + lib +) + +target_link_libraries(${MY_TARGET} PRIVATE + cute +) + +# Set the WIN32_EXECUTABLE property conditionally for Release, MinSizeRel, and RelWithDebInfo builds. +# This lets the exe run without a terminal, making stdout inaccessible for now. +if(WIN32) + set_target_properties(${MY_TARGET} PROPERTIES WIN32_EXECUTABLE $<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>,$<CONFIG:RelWithDebInfo>>) +endif(WIN32) + +# Use this command to copy the .dll from the lib folder next to the freshly built .exe. Which is the most simple way to get it working. +add_custom_command(TARGET ${MY_TARGET} POST_BUILD # Adds a post-build event to DynamicDemo + COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..." + "${PROJECT_SOURCE_DIR}/lib/cute.dll" # <--this is in-file + $<TARGET_FILE_DIR:${MY_TARGET}>) # <--this is out-file path