Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 9bfdd28

Browse files
committed
Replace OPENCENSUS_INCLUDE_DIR with CMAKE_SOURCE_DIR
1 parent bd876f6 commit 9bfdd28

File tree

2 files changed

+102
-102
lines changed

2 files changed

+102
-102
lines changed

CMakeLists.txt

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
# Copyright 2018, OpenCensus Authors
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
cmake_minimum_required(VERSION 3.5)
16-
17-
# Use ccache if it's present.
18-
find_program(CCACHE_PROGRAM ccache)
19-
if(CCACHE_PROGRAM)
20-
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
21-
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}")
22-
endif()
23-
24-
project(opencensus-cpp VERSION 0.3.0 LANGUAGES CXX)
25-
26-
set(CMAKE_CXX_STANDARD 11)
27-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
28-
set(OPENCENSUS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
29-
30-
include(CTest) # Defines option BUILD_TESTING.
31-
enable_testing()
32-
33-
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
34-
include(OpenCensusDeps)
35-
include(OpenCensusHelpers)
36-
37-
# OpenCensus code.
38-
add_subdirectory(opencensus)
39-
40-
# Example code only if testing is enabled.
41-
if(BUILD_TESTING)
42-
add_subdirectory(examples)
43-
endif()
1+
# Copyright 2018, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
cmake_minimum_required(VERSION 3.5)
16+
17+
# Use ccache if it's present.
18+
find_program(CCACHE_PROGRAM ccache)
19+
if(CCACHE_PROGRAM)
20+
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
21+
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CCACHE_PROGRAM}")
22+
endif()
23+
24+
project(opencensus-cpp VERSION 0.3.0 LANGUAGES CXX)
25+
26+
set(CMAKE_CXX_STANDARD 11)
27+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
28+
29+
include(CTest) # Defines option BUILD_TESTING.
30+
enable_testing()
31+
32+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
33+
include(OpenCensusDeps)
34+
35+
include(OpenCensusHelpers)
36+
37+
# OpenCensus code.
38+
add_subdirectory(opencensus)
39+
40+
# Example code only if testing is enabled.
41+
if(BUILD_TESTING)
42+
add_subdirectory(examples)
43+
endif()

cmake/OpenCensusHelpers.cmake

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
# Copyright 2018, OpenCensus Authors
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
# Prepends opencensus_ to all deps that aren't in a :: namespace.
16-
function(prepend_opencensus OUT DEPS)
17-
set(_DEPS "")
18-
foreach(dep ${DEPS})
19-
if("${dep}" MATCHES "::")
20-
list(APPEND _DEPS "${dep}")
21-
else()
22-
list(APPEND _DEPS "opencensus_${dep}")
23-
endif()
24-
endforeach()
25-
set(${OUT} ${_DEPS} PARENT_SCOPE)
26-
endfunction()
27-
28-
# Helper function like bazel's cc_test. Usage:
29-
#
30-
# opencensus_test(trace_some_test internal/some_test.cc dep1 dep2...)
31-
function(opencensus_test NAME SRC)
32-
if(BUILD_TESTING)
33-
set(_NAME "opencensus_${NAME}")
34-
add_executable(${_NAME} ${SRC})
35-
prepend_opencensus(DEPS "${ARGN}")
36-
target_link_libraries(${_NAME} "${DEPS}" gmock gtest_main)
37-
add_test(NAME ${_NAME} COMMAND ${_NAME})
38-
endif()
39-
endfunction()
40-
41-
# Helper function like bazel's cc_library. Libraries are namespaced as
42-
# opencensus_* and public libraries are also aliased as opencensus-cpp::*.
43-
function(opencensus_lib NAME)
44-
cmake_parse_arguments(ARG "PUBLIC" "" "SRCS;DEPS" ${ARGN})
45-
set(_NAME "opencensus_${NAME}")
46-
prepend_opencensus(ARG_DEPS "${ARG_DEPS}")
47-
if(ARG_SRCS)
48-
add_library(${_NAME} ${ARG_SRCS})
49-
target_link_libraries(${_NAME} PUBLIC ${ARG_DEPS})
50-
target_include_directories(${_NAME} PUBLIC ${OPENCENSUS_INCLUDE_DIR})
51-
else()
52-
add_library(${_NAME} INTERFACE)
53-
target_link_libraries(${_NAME} INTERFACE ${ARG_DEPS})
54-
target_include_directories(${_NAME} INTERFACE ${OPENCENSUS_INCLUDE_DIR})
55-
endif()
56-
if(ARG_PUBLIC)
57-
add_library(${PROJECT_NAME}::${NAME} ALIAS ${_NAME})
58-
endif()
59-
endfunction()
1+
# Copyright 2018, OpenCensus Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Prepends opencensus_ to all deps that aren't in a :: namespace.
16+
function(prepend_opencensus OUT DEPS)
17+
set(_DEPS "")
18+
foreach(dep ${DEPS})
19+
if("${dep}" MATCHES "::")
20+
list(APPEND _DEPS "${dep}")
21+
else()
22+
list(APPEND _DEPS "opencensus_${dep}")
23+
endif()
24+
endforeach()
25+
set(${OUT} ${_DEPS} PARENT_SCOPE)
26+
endfunction()
27+
28+
# Helper function like bazel's cc_test. Usage:
29+
#
30+
# opencensus_test(trace_some_test internal/some_test.cc dep1 dep2...)
31+
function(opencensus_test NAME SRC)
32+
if(BUILD_TESTING)
33+
set(_NAME "opencensus_${NAME}")
34+
add_executable(${_NAME} ${SRC})
35+
prepend_opencensus(DEPS "${ARGN}")
36+
target_link_libraries(${_NAME} "${DEPS}" gmock gtest_main)
37+
add_test(NAME ${_NAME} COMMAND ${_NAME})
38+
endif()
39+
endfunction()
40+
41+
# Helper function like bazel's cc_library. Libraries are namespaced as
42+
# opencensus_* and public libraries are also aliased as opencensus-cpp::*.
43+
function(opencensus_lib NAME)
44+
cmake_parse_arguments(ARG "PUBLIC" "" "SRCS;DEPS" ${ARGN})
45+
set(_NAME "opencensus_${NAME}")
46+
prepend_opencensus(ARG_DEPS "${ARG_DEPS}")
47+
if(ARG_SRCS)
48+
add_library(${_NAME} ${ARG_SRCS})
49+
target_link_libraries(${_NAME} PUBLIC ${ARG_DEPS})
50+
target_include_directories(${_NAME} PUBLIC ${CMAKE_SOURCE_DIR})
51+
else()
52+
add_library(${_NAME} INTERFACE)
53+
target_link_libraries(${_NAME} INTERFACE ${ARG_DEPS})
54+
target_include_directories(${_NAME} INTERFACE ${CMAKE_SOURCE_DIR})
55+
endif()
56+
if(ARG_PUBLIC)
57+
add_library(${PROJECT_NAME}::${NAME} ALIAS ${_NAME})
58+
endif()
59+
endfunction()

0 commit comments

Comments
 (0)