Files
jtest/CMakeLists.txt

69 lines
1.7 KiB
CMake

# 2024 Josh O'Leary @ Redacted Software
cmake_minimum_required(VERSION 3.18...3.25)
project(
jtest
VERSION 1.0
LANGUAGES CXX
)
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed!")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(cmake/CPM.cmake)
######################
# Create a library
file(GLOB_RECURSE jtest_HEADERS "include/jtest/*.h" "include/jtest/*.hpp")
file(GLOB_RECURSE jtest_SRC "src/jtest/*.c" "src/jtest/*.cpp")
# TODO: Fix Event needing to be included too, it should be an automatically-managed depencency of jlog!!!
CPMAddPackage(
NAME Event
URL https://git.redacted.cc/josh/Event/archive/Release-6.zip
)
CPMAddPackage(
NAME jlog
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-8.zip
)
if (UNIX)
add_library(jtest SHARED ${jtest_SRC})
endif()
if (WIN32)
add_library(jtest STATIC ${jtest_SRC})
endif()
target_include_directories(jtest PUBLIC ${Event_SOURCE_DIR}/include)
target_include_directories(jtest PUBLIC ${jlog_SOURCE_DIR}/include)
target_include_directories(jtest PUBLIC ${PROJECT_SOURCE_DIR}/include)
set_target_properties(jtest PROPERTIES LINKER_LANGUAGE CXX)
install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})
install(FILES ${jtest_HEADERS} DESTINATION include/${PROJECT_NAME})
####################
# Create Executable
target_link_libraries(jtest PUBLIC Event jlog)
# Add an executable with main srces
add_executable(TestSuiteDemo main.cpp)
# link the new library target with the binary target
target_link_libraries(TestSuiteDemo PUBLIC jtest)