Skip to content

Commit

Permalink
Clean up the build system a bit.
Browse files Browse the repository at this point in the history
This commit changes the directory structure by moving the library to a new directory called: observable.
  • Loading branch information
ddinu committed Apr 29, 2018
1 parent 0658caf commit 618c4e5
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 39 deletions.
27 changes: 4 additions & 23 deletions CMakeLists.txt
@@ -1,32 +1,13 @@
project(observable)
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.2)
enable_testing()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "")
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "cmake")

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(default_source_groups)

set(SOURCE_FILES include/observable/observable.hpp
include/observable/observe.hpp
include/observable/subject.hpp
include/observable/subscription.hpp
include/observable/value.hpp
include/observable/expressions/expression.hpp
include/observable/expressions/filters.hpp
include/observable/expressions/math.hpp
include/observable/expressions/operators.hpp
include/observable/expressions/tree.hpp
include/observable/expressions/utility.hpp
include/observable/detail/collection.hpp
include/observable/detail/type_traits.hpp)

add_library(observable INTERFACE)
target_include_directories(observable INTERFACE include)

# Dummy target to get a project in IDEs.
add_custom_target(observable_headers SOURCES ${SOURCE_FILES})

add_subdirectory(observable)
add_subdirectory(external)
add_subdirectory(tests)
add_subdirectory(benchmark)
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -7,8 +7,8 @@ pattern, this is for you.
Quick start
-----------

The library is header-only and has no dependencies; copy the
``include/observable`` directory into your include path and you're set.
The library is header-only and has no dependencies; add the
``observable/include`` directory to your include path and you're set.

Example:

Expand Down
35 changes: 22 additions & 13 deletions cmake/compile_flags.cmake
Expand Up @@ -4,26 +4,35 @@
# - target_name Name of the configured target.
function(enable_strict_warnings target_name)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
set(release /Wall /wd4820 /wd4514 /wd4625 /wd4626 /wd4627 /wd5026
/wd5027 /wd4710 /wd4668 /wd4711 /wd4548 /wd4868 /wd4571)
set(debug /WX)
target_compile_options(${target_name}
PRIVATE
/Wall /wd4820 /wd4514 /wd4625 /wd4626 /wd4627 /wd5026
/wd5027 /wd4710 /wd4668 /wd4711 /wd4548 /wd4868 /wd4571

$<$<CONFIG:Debug>:/WX>
)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(release -Wall -Wextra -pedantic -Wshadow -Wabi)
set(debug -Werror)
target_compile_options(${target_name}
PRIVATE
-Wall -Wextra -pedantic -Wshadow -Wabi

$<$<CONFIG:Debug>:-Werror>
)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
set(release -Weverything -Wno-system-headers -Wabi -Wno-c++98-compat
-Wno-c++98-compat-pedantic -Wno-exit-time-destructors
-Wno-global-constructors -Wno-missing-prototypes
-Wno-padded -Wno-documentation-unknown-command)
set(debug -Werror)
target_compile_options(${target_name}
PRIVATE
-Weverything -Wno-system-headers -Wabi -Wno-c++98-compat
-Wno-c++98-compat-pedantic -Wno-exit-time-destructors
-Wno-global-constructors -Wno-missing-prototypes
-Wno-padded -Wno-documentation-unknown-command

$<$<CONFIG:Debug>:-Werror>
)
else()
message(WARNING "Custom compiler flags not set.\n"
"Your compiler is not supported.\n"
"Detected id is '${CMAKE_CXX_COMPILER_ID}'.")
endif()

target_compile_options(${target_name} PRIVATE ${release})
target_compile_options(${target_name} PRIVATE $<$<CONFIG:Debug>:${debug}>)
endfunction(enable_strict_warnings)

# Disablee all warnings.
Expand Down
2 changes: 1 addition & 1 deletion docs/doxygen/Doxyfile
@@ -1,7 +1,7 @@
PROJECT_NAME = "Observable Reference"
PROJECT_BRIEF = "Generic observable objects for C++"
OUTPUT_DIRECTORY = ${OUTPUT_DIR}
INPUT = ${CMAKE_SOURCE_DIR}/include/observable
INPUT = ${CMAKE_SOURCE_DIR}/observable/include/observable
LAYOUT_FILE = ${CMAKE_CURRENT_SOURCE_DIR}/DoxygenLayout.xml

JAVADOC_AUTOBRIEF = YES
Expand Down
33 changes: 33 additions & 0 deletions observable/CMakeLists.txt
@@ -0,0 +1,33 @@
add_library(observable INTERFACE)

add_custom_target(observable_headers # Just to generate a project in IDEs.
SOURCES
include/observable/observable.hpp
include/observable/observe.hpp
include/observable/subject.hpp
include/observable/subscription.hpp
include/observable/value.hpp
include/observable/expressions/expression.hpp
include/observable/expressions/filters.hpp
include/observable/expressions/math.hpp
include/observable/expressions/operators.hpp
include/observable/expressions/tree.hpp
include/observable/expressions/utility.hpp
include/observable/detail/collection.hpp
include/observable/detail/type_traits.hpp
)

target_include_directories(observable
INTERFACE
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

install(TARGETS observable EXPORT Observable
INCLUDES DESTINATION include
)

install(EXPORT Observable NAMESPACE Observable::
FILE ObservableTargets.cmake
DESTINATION lib/cmake/observable)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 618c4e5

Please sign in to comment.