CMakeLists.txt 1.5 KB
Newer Older
1 2
# List all required files here (cmake best practice to NOT automate this step!)
add_library(pls STATIC
3 4 5 6 7 8 9
            src/library.cpp include/pls/library.h
            src/internal/base/thread.cpp include/pls/internal/base/thread.h)

# Settings for our project...
# ...pthreads or C++ 11 threads
option(USING_PTHREADS "Build the tests" ON)
if(USING_PTHREADS)
10
    target_compile_definitions(pls PUBLIC PLS_USING_PTHREADS)
11
else()
12
    target_compile_definitions(pls PUBLIC PLS_USING_CPP_THREADS)
13
endif()
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

# Add everything in `./include` to be in the include path of this project
target_include_directories(pls
        PUBLIC
            $<INSTALL_INTERFACE:include>
            $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
        PRIVATE
            ${CMAKE_CURRENT_SOURCE_DIR}/src # TODO: Set this up when we require private headers
)

# Add cmake dependencies here if needed
target_link_libraries(pls
        Threads::Threads # pthread support
)

# Rules for istalling the library on a system
# ...binaries
install(TARGETS pls
        LIBRARY
            DESTINATION lib
        ARCHIVE
            DESTINATION lib
)
# ...all headers in `include`
INSTALL (
        DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
        DESTINATION include
        FILES_MATCHING PATTERN "*.h*"
)

# Enable warnings/tidy code checking from our compiler
target_compile_options(pls PRIVATE
        $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
        -Wall>
        $<$<CXX_COMPILER_ID:MSVC>:
        -W4>)