cmake_minimum_required(VERSION 3.16) project(iZo VERSION 0.1.0 LANGUAGES CXX) add_library(izo STATIC) add_library(iZo::izo ALIAS izo) target_sources(izo PRIVATE src/command_line.cpp src/dialogs.cpp src/directory_watcher.cpp src/process.cpp src/time.cpp $<$:src/interaction_windows.cpp> $<$:src/platform_windows.cpp> $<$:src/interaction_linux.cpp> $<$:src/platform_linux.cpp> $<$:src/dialogs_windows.cpp> $<$:src/dialogs_linux.cpp> ) target_include_directories(izo PUBLIC $ $ ) target_compile_features(izo PUBLIC cxx_std_17) set_target_properties(izo PROPERTIES CXX_EXTENSIONS OFF OUTPUT_NAME izo ) if(WIN32) target_compile_definitions(izo PRIVATE UNICODE _UNICODE WIN32_LEAN_AND_MEAN NOMINMAX) target_link_libraries(izo PRIVATE advapi32 comdlg32 ole32 shell32 uuid user32) elseif(UNIX AND NOT APPLE) # No link-time desktop dependency. The Linux backend discovers zenity or # kdialog at runtime so applications do not inherit GTK or Qt dependencies. target_link_libraries(izo PRIVATE dl) else() message(FATAL_ERROR "iZo currently supports Windows and Linux") endif() include(GNUInstallDirs) include(CMakePackageConfigHelpers) install(TARGETS izo EXPORT iZoTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(EXPORT iZoTargets FILE iZoTargets.cmake NAMESPACE iZo:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/iZo ) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/iZoConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) configure_package_config_file( cmake/iZoConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/iZoConfig.cmake" INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/iZo ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/iZoConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/iZoConfigVersion.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/iZo ) option(IZO_BUILD_EXAMPLE "Build the iZo example program" OFF) if(IZO_BUILD_EXAMPLE) add_executable(izo_example examples/dialogs.cpp) target_link_libraries(izo_example PRIVATE iZo::izo) endif() option(IZO_BUILD_TESTS "Build the iZo tests" OFF) if(IZO_BUILD_TESTS) if(NOT UNIX OR APPLE) message(FATAL_ERROR "iZo unit tests currently require Linux") endif() enable_testing() function(izo_add_test name) add_executable(izo_test_${name} tests/${name}.cpp) target_link_libraries(izo_test_${name} PRIVATE iZo::izo) add_test(NAME ${name} COMMAND izo_test_${name}) set_tests_properties(${name} PROPERTIES TIMEOUT 10) endfunction() izo_add_test(environment_paths) izo_add_test(command_line) izo_add_test(system_time_debug) izo_add_test(dynamic_library) izo_add_test(process) izo_add_test(directory_watcher) izo_add_test(headless_interaction) endif()