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

# Settings for our project...
# ...pthreads or C++ 11 threads
option(USING_PTHREADS "Build the tests" ON)
if(USING_PTHREADS)
13
    target_compile_definitions(pls PUBLIC PLS_USING_PTHREADS)
14
else()
15
    target_compile_definitions(pls PUBLIC PLS_USING_CPP_THREADS)
16
endif()
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 50 51

# 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>:
52
        -W4>)