Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
compass-github-pull
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
steinbac
compass-github-pull
Commits
bf7d9301
Commit
bf7d9301
authored
Apr 13, 2018
by
steinbac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added single-header variant
parent
bc9365e4
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1128 additions
and
33 deletions
+1128
-33
CMakeLists.txt
CMakeLists.txt
+35
-5
single_include/compass.hpp
single_include/compass.hpp
+1067
-0
tests/CMakeLists.txt
tests/CMakeLists.txt
+26
-28
No files found.
CMakeLists.txt
View file @
bf7d9301
# cmake compatibility issues
CMAKE_MINIMUM_REQUIRED
(
VERSION 3.
1
)
CMAKE_MINIMUM_REQUIRED
(
VERSION 3.
8
)
# project name
PROJECT
(
compass CXX
)
...
...
@@ -25,7 +25,12 @@ SET (COMPASS_ID "${COMPASS_VENDOR_ID}.${PROJECT_NAME}")
option
(
WITH_CXX11_ABI
"enable _GLIBCXX_USE_CXX11_ABI in GCC 5.0+"
ON
)
option
(
WITH_TESTS
"enable unit tests"
ON
)
option
(
WITH_SINGLE_HEADER
"produce single header file from include/"
OFF
)
option
(
WITH_SINGLE_HEADER
"use single header file from single-header/"
OFF
)
option
(
GENERATE_SINGLE_HEADER
"run pcpp on include/ and produce single-header"
OFF
)
if
(
GENERATE_SINGLE_HEADER
)
set
(
WITH_SINGLE_HEADER ON CACHED
)
endif
()
check_cxx_compiler_flag
(
-Wl,-Bsymbolic HAS_BSYMBOLIC_COMPILERFLAG
)
check_cxx_compiler_flag
(
"-Xclang -march=native"
HAS_XCLANG_COMPILERFLAG
)
...
...
@@ -48,11 +53,12 @@ set(COMPASS_CMAKE_VERSION_CONFIG_FILE "${COMPASS_CMAKE_CONFIG_DIR}/${PROJECT_NAM
set
(
COMPASS_CMAKE_PROJECT_CONFIG_FILE
"
${
COMPASS_CMAKE_CONFIG_DIR
}
/
${
PROJECT_NAME
}
Config.cmake"
)
set
(
COMPASS_CMAKE_PROJECT_TARGETS_FILE
"
${
COMPASS_CMAKE_CONFIG_DIR
}
/
${
PROJECT_NAME
}
Targets.cmake"
)
if
(
NOT WITH_SINGLE_HEADER
)
set
(
COMPASS_INCLUDE_BUILD_DIR
"
${
PROJECT_SOURCE_DIR
}
/include
/
"
)
set
(
COMPASS_INCLUDE_BUILD_DIR
"
${
PROJECT_SOURCE_DIR
}
/include"
)
message
(
STATUS
"Using the multi-header code from
${
COMPASS_INCLUDE_BUILD_DIR
}
"
)
else
()
set
(
COMPASS_INCLUDE_BUILD_DIR
"
${
PROJECT_SOURCE_DIR
}
/single_include
/
"
)
set
(
COMPASS_INCLUDE_BUILD_DIR
"
${
PROJECT_SOURCE_DIR
}
/single_include"
)
message
(
STATUS
"Using the single-header code from
${
COMPASS_INCLUDE_BUILD_DIR
}
"
)
endif
()
...
...
@@ -69,6 +75,30 @@ target_compile_definitions(${COMPASS_TARGET_NAME}
INTERFACE cxx_std_11
)
## ============== generate single-header ================
if
(
${
GENERATE_SINGLE_HEADER
}
)
find_program
(
PCPP NAMES pcpp PATH
${
PCPP_PATH
}
PATH_SUFFIXES bin NO_DEFAULT_PATH
)
find_program
(
PCPP NAMES pcpp
)
if
(
EXISTS
${
PCPP
}
)
message
(
STATUS
"pcpp found at
${
PCPP
}
"
)
if
(
NOT EXISTS
${
COMPASS_INCLUDE_BUILD_DIR
}
)
file
(
MAKE_DIRECTORY
${
COMPASS_INCLUDE_BUILD_DIR
}
)
message
(
"created
${
COMPASS_INCLUDE_BUILD_DIR
}
"
)
endif
()
execute_process
(
COMMAND
${
PCPP
}
-o
${
COMPASS_INCLUDE_BUILD_DIR
}
/compass.hpp --line-directive --passthru-defines --passthru-unfound-includes --passthru-unknown-exprs
${
PROJECT_SOURCE_DIR
}
/include/compass.hpp
WORKING_DIRECTORY
${
PROJECT_SOURCE_DIR
}
RESULT_VARIABLE PCPP_RESULT
)
if
(
${
PCPP_RESULT
}
EQUAL 0
)
message
(
STATUS
"Preprocessed
${
PROJECT_SOURCE_DIR
}
/include/compass.hpp into
${
COMPASS_INCLUDE_BUILD_DIR
}
/compass.hpp"
)
else
()
message
(
FATAL_ERROR
"Preprocessing
${
PROJECT_SOURCE_DIR
}
/include/compass.hpp into
${
COMPASS_INCLUDE_BUILD_DIR
}
/compass.hpp failed"
)
endif
()
else
()
message
(
FATAL_ERROR
"pcpp not found (
${
PCPP_PATH
}
${
PCPP_FOUND
}
), unable to continue in single-header configuration"
)
endif
()
endif
()
#target_sources(compass INTERFACE include/compass.hpp)
...
...
@@ -116,7 +146,7 @@ install(
NAMESPACE
${
PROJECT_NAME
}
::
DESTINATION
${
COMPASS_CONFIG_INSTALL_DIR
}
)
install
(
DIRECTORY
"
${
C
MAKE_CURRENT_SOURCE_DIR
}
/include/
"
install
(
DIRECTORY
"
${
C
OMPASS_INCLUDE_BUILD_DIR
}
"
DESTINATION include
FILES_MATCHING
PATTERN
"*.hpp"
...
...
single_include/compass.hpp
0 → 100644
View file @
bf7d9301
This diff is collapsed.
Click to expand it.
tests/CMakeLists.txt
View file @
bf7d9301
...
...
@@ -13,15 +13,23 @@ ExternalProject_Add(
)
ExternalProject_Get_Property
(
catch2 DOWNLOAD_DIR
)
set
(
CATCH2_HEADER_PATH
${
DOWNLOAD_DIR
}
)
message
(
STATUS
"catch2 header file download to
${
CATCH2_HEADER_PATH
}
"
)
add_library
(
catcho OBJECT catch.cpp
)
target_include_directories
(
catcho PUBLIC
${
CATCH2_HEADER_PATH
}
)
add_dependencies
(
catcho catch2
)
# prepping tests
add_executable
(
test_compass_impl test_compass_impl.cpp $<TARGET_OBJECTS:catcho>
)
target_include_directories
(
test_compass_impl PRIVATE
${
CATCH2_HEADER_PATH
}
${
COMPASS_INCLUDE_BUILD_DIR
}
)
add_executable
(
test_bitview test_bitview.cpp $<TARGET_OBJECTS:catcho>
)
target_include_directories
(
test_bitview PRIVATE
${
PROJECT_SOURCE_DIR
}
/include
${
CATCH2_HEADER_PATH
}
)
#idea for generating test fixture at cmake-invocation
#Windows 7: use `wmic cpu GET Name` to obtain clearname of CPU model
#Linux : use `lscpu` or `/proc/cpuinfo` to obtain more data about
#macOS : not sure yet what to use
cmake_host_system_information
(
RESULT CURRENT_HOSTNAME QUERY HOSTNAME
)
...
...
@@ -35,33 +43,23 @@ if(${CURRENT_HOSTNAME} MATCHES ".*(falcon2|talisker|schorle|scicomp-pc-3|recover
endif
()
#idea for generating test fixture at cmake-invocation
#Windows 7: use `wmic cpu GET Name` to obtain clearname of CPU model
#Linux : use `lscpu` or `/proc/cpuinfo` to obtain more data about
#macOS : not sure yet what to use
add_executable
(
test_compass_impl test_compass_impl.cpp $<TARGET_OBJECTS:catcho>
)
target_include_directories
(
test_compass_impl PRIVATE
${
CATCH2_HEADER_PATH
}
${
COMPASS_INCLUDE_BUILD_DIR
}
)
add_executable
(
test_bitview test_bitview.cpp $<TARGET_OBJECTS:catcho>
)
target_include_directories
(
test_bitview PRIVATE
${
PROJECT_SOURCE_DIR
}
/include
${
CATCH2_HEADER_PATH
}
)
### test single header
if
(
WITH_SINGLE_HEADER
)
find_program
(
PCPP NAME pcpp HINT
${
PCPP_PATH
}
)
if
(
PCPP_FOUND OR EXISTS
${
PCPP_PATH
}
)
add_custom_target
(
sh
COMMAND pcpp -o
${
PROJECT_BINARY_DIR
}
/tests/compass-sh.hpp --line-directive --passthru-defines --passthru-unfound-includes --passthru-unknown-exprs
${
PROJECT_SOURCE_DIR
}
/include/compass.hpp
BYPRODUCTS
${
CMAKE_CURRENT_BINARY_DIR
}
/compass-sh.hpp
COMMENT
"Preprocessing
${
PROJECT_SOURCE_DIR
}
/include/compass.hpp into
${
CMAKE_CURRENT_BINARY_DIR
}
/tests/compass-sh.hpp ..."
USES_TERMINAL
)
#
if(WITH_SINGLE_HEADER)
#
find_program(PCPP NAME pcpp HINT ${PCPP_PATH})
#
if(PCPP_FOUND OR EXISTS ${PCPP_PATH})
#
add_custom_target(sh
#
COMMAND pcpp -o ${PROJECT_BINARY_DIR}/tests/compass-sh.hpp --line-directive --passthru-defines --passthru-unfound-includes --passthru-unknown-exprs ${PROJECT_SOURCE_DIR}/include/compass.hpp
#
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/compass-sh.hpp
#
COMMENT "Preprocessing ${PROJECT_SOURCE_DIR}/include/compass.hpp into ${CMAKE_CURRENT_BINARY_DIR}/tests/compass-sh.hpp ..."
#
USES_TERMINAL)
add_executable
(
test_single_header test_single_header.cpp $<TARGET_OBJECTS:catcho>
${
CMAKE_CURRENT_BINARY_DIR
}
/compass-sh.hpp
)
add_dependencies
(
test_single_header sh
)
target_include_directories
(
test_single_header PRIVATE
${
PROJECT_BINARY_DIR
}
/tests
${
CATCH2_HEADER_PATH
}
)
#
add_executable(test_single_header test_single_header.cpp $<TARGET_OBJECTS:catcho> ${CMAKE_CURRENT_BINARY_DIR}/compass-sh.hpp)
#
add_dependencies(test_single_header sh)
#
target_include_directories(test_single_header PRIVATE ${PROJECT_BINARY_DIR}/tests ${CATCH2_HEADER_PATH})
else
()
message
(
WARNING
"pcpp not found
${
PCPP_PATH
}
"
)
endif
()
#
else()
#
message(WARNING "pcpp not found ${PCPP_PATH}")
#
endif()
endif
()
#
endif()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment