🎨 Convert to a header-only library (#6)

This commit is contained in:
2021-01-12 16:19:25 +01:00
committed by GitHub
parent f7fe31739e
commit c7b0151510
19 changed files with 1090 additions and 1404 deletions

View File

@ -1,55 +1,21 @@
#-------------------------------------------------------
# moFileReader Main Build Script
#
# Defined Variables:
# - COMPILE_DLL
# - ON : Compiles the code as a shared Library
# - OFF : Compiles the code as a static Library
# - BUILD_DEBUG
# - ON : Compiles Debug-Information into the output
# - OFF : Optimizes the compilation with O2.
#
# Run cmake with -DVARNAME=ON/OFF to benefit from those
# possible settings.
#-------------------------------------------------------
cmake_minimum_required(VERSION 3.0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 11)
project(moFileReader)
# Let the user choose between static lib and dll
# To use it, call cmake -DCOMPILE_DLL=ON
option(COMPILE_DLL "Set this to ON if you want to compile the library as an DLL. When this is OFF, a static library is created (default)." OFF)
if (COMPILE_DLL)
# DLL
target_compile_definitions(moReader PRIVATE _USRDLL MOFILE_EXPORTS)
endif ()
add_library(moFileReader STATIC ${CMAKE_SOURCE_DIR}/src/moFileReader.cpp ${CMAKE_SOURCE_DIR}/src/mo.cpp)
add_executable(moReader ${CMAKE_SOURCE_DIR}/src/mo.cpp)
target_include_directories(moFileReader PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_include_directories(moReader PRIVATE ${CMAKE_SOURCE_DIR}/include)
if (COMPILE_DLL)
target_compile_definitions(moReader PRIVATE _CONSOLE MOFILE_IMPORT)
else ()
target_compile_definitions(moReader PRIVATE _CONSOLE)
endif ()
add_dependencies(moReader moFileReader)
target_link_libraries(moReader moFileReader)
install(TARGETS moReader
RUNTIME DESTINATION bin
)
install(TARGETS moFileReader
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/)
option(BUILD_TEST "Set this to ON if you want to build the test" OFF)