Skip to content

Commit

Permalink
Reorganized source code
Browse files Browse the repository at this point in the history
  • Loading branch information
travnick committed Aug 12, 2019
1 parent 02fe580 commit cfc34b8
Show file tree
Hide file tree
Showing 8 changed files with 367 additions and 359 deletions.
75 changes: 13 additions & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,22 @@ cmake_minimum_required(VERSION 3.10)

project(NamedType CXX)

set(librarySources
"crtp.hpp"
"named_type.hpp"
"named_type_impl.hpp"
"underlying_functionalities.hpp"
)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13")
cmake_policy(SET CMP0076 NEW)
endif()

add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE .)

set(ENABLE_TESTS ON CACHE BOOL "Enable tests")

if (ENABLE_TESTS)
enable_testing()

set(TestTargetName "${PROJECT_NAME}Test")
target_include_directories(${PROJECT_NAME} INTERFACE "include/")

set(testSources
${librarySources}
"main.cpp"
"catch.hpp"
)

add_executable(${TestTargetName} ${testSources})

set_property(TARGET ${TestTargetName} PROPERTY CXX_STANDARD 17)

if (MSVC)
string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
target_sources(${PROJECT_NAME} INTERFACE
"include/NamedType/crtp.hpp"
"include/NamedType/named_type.hpp"
"include/NamedType/named_type_impl.hpp"
"include/NamedType/underlying_functionalities.hpp"
)

target_compile_options(
${TestTargetName}
PRIVATE
"/W4"
"/WX"
"/diagnostics:caret"
)
else()
target_compile_options(
${TestTargetName}
PRIVATE
-Wall
-Wcast-align
-Wcast-qual
-Wconversion
-Wctor-dtor-privacy
-Wdouble-promotion
-Werror
-Wextra
-Wlogical-op
-Wnoexcept
-Wold-style-cast
-Woverloaded-virtual
-Wpedantic
-Wredundant-decls
-Wstack-protector
-Wstrict-null-sentinel
-Wzero-as-null-pointer-constant
-Wfloat-equal
-Wshadow
-Wuseless-cast
-Weffc++
)
endif()
set(ENABLE_TEST ON CACHE BOOL "Enable test")

add_test(NAME ${TestTargetName} COMMAND ${TestTargetName})
if (ENABLE_TEST)
add_subdirectory(test)
endif()
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions named_type_impl.hpp → include/NamedType/named_type_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
# define FLUENT_EBCO
#endif

#if defined(__clang__) || defined(__GNUC__)
# define IGNORE_SHOULD_RETURN_REFERENCE_TO_THIS_BEGIN \
_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Weffc++\"")
# define IGNORE_SHOULD_RETURN_REFERENCE_TO_THIS_END _Pragma("GCC diagnostic pop")
#else
# define IGNORE_SHOULD_RETURN_REFERENCE_TO_THIS_BEGIN /* Nothing */
# define IGNORE_SHOULD_RETURN_REFERENCE_TO_THIS_END /* Nothing */
#if defined(__clang__) || defined(__GNUC__)
# define IGNORE_SHOULD_RETURN_REFERENCE_TO_THIS_BEGIN \
_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Weffc++\"")
# define IGNORE_SHOULD_RETURN_REFERENCE_TO_THIS_END _Pragma("GCC diagnostic pop")
#else
# define IGNORE_SHOULD_RETURN_REFERENCE_TO_THIS_BEGIN /* Nothing */
# define IGNORE_SHOULD_RETURN_REFERENCE_TO_THIS_END /* Nothing */
#endif

namespace fluent
Expand Down
File renamed without changes.
57 changes: 57 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
cmake_minimum_required(VERSION 3.10)

project(NamedTypeTest CXX)

enable_testing()

set(testSources
"main.cpp"
"catch.hpp"
)

add_executable(${PROJECT_NAME} ${testSources})

target_include_directories(${PROJECT_NAME} PUBLIC "${NamedType_SOURCE_DIR}/include/")

set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)

if (MSVC)
string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

target_compile_options(
${PROJECT_NAME}
PRIVATE
"/W4"
"/WX"
"/diagnostics:caret"
)
else()
target_compile_options(
${PROJECT_NAME}
PRIVATE
-Wall
-Wcast-align
-Wcast-qual
-Wconversion
-Wctor-dtor-privacy
-Wdouble-promotion
-Werror
-Wextra
-Wlogical-op
-Wnoexcept
-Wold-style-cast
-Woverloaded-virtual
-Wpedantic
-Wredundant-decls
-Wstack-protector
-Wstrict-null-sentinel
-Wzero-as-null-pointer-constant
-Wfloat-equal
-Wshadow
-Wuseless-cast
-Weffc++
)
endif()

add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})
Loading

0 comments on commit cfc34b8

Please sign in to comment.