Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
ae36935d
Commit
ae36935d
authored
Oct 19, 2014
by
Philip Quinn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support disabling builds of the command-line tools and unit tests, and using an external compiler.
parent
4157aa8f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
58 deletions
+109
-58
CMakeLists.txt
c++/CMakeLists.txt
+9
-0
CMakeLists.txt
c++/src/CMakeLists.txt
+100
-58
No files found.
c++/CMakeLists.txt
View file @
ae36935d
option
(
BUILD_TOOLS
"Build command-line tools and compiler."
ON
)
option
(
BUILD_TESTING
"Build unit tests and enable CTest 'check' target."
ON
)
option
(
EXTERNAL_CAPNP
"Use the system capnp binary, or the one specified in $CAPNP, instead of using the compiled one."
OFF
)
if
(
NOT BUILD_TOOLS AND BUILD_TESTING AND NOT EXTERNAL_CAPNP
)
message
(
WARNING
"Forcing BUILD_TOOLS to ON; required by BUILD_TESTING without EXTERNAL_CAPNP."
)
set
(
BUILD_TOOLS TRUE
)
endif
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wno-unused-parameter -std=c++11 -pthread"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Wno-unused-parameter -std=c++11 -pthread"
)
add_subdirectory
(
src
)
add_subdirectory
(
src
)
c++/src/CMakeLists.txt
View file @
ae36935d
...
@@ -148,41 +148,57 @@ set(capnpc_headers
...
@@ -148,41 +148,57 @@ set(capnpc_headers
capnp/rpc-twoparty.capnp
capnp/rpc-twoparty.capnp
)
)
add_executable
(
capnp-tool
if
(
BUILD_TOOLS
)
add_executable
(
capnp-tool
capnp/compiler/module-loader.c++
capnp/compiler/module-loader.c++
capnp/compiler/capnp.c++
capnp/compiler/capnp.c++
)
)
target_link_libraries
(
capnp-tool capnpc capnp kj
)
target_link_libraries
(
capnp-tool capnpc capnp kj
)
set_target_properties
(
capnp-tool PROPERTIES OUTPUT_NAME capnp
)
set_target_properties
(
capnp-tool PROPERTIES OUTPUT_NAME capnp
)
add_executable
(
capnpc_cpp
add_executable
(
capnpc_cpp
capnp/compiler/capnpc-c++.c++
capnp/compiler/capnpc-c++.c++
)
)
target_link_libraries
(
capnpc_cpp capnp kj
)
target_link_libraries
(
capnpc_cpp capnp kj
)
set_target_properties
(
capnpc_cpp PROPERTIES OUTPUT_NAME capnpc-c++
)
set_target_properties
(
capnpc_cpp PROPERTIES OUTPUT_NAME capnpc-c++
)
add_executable
(
capnpc_capnp
add_executable
(
capnpc_capnp
capnp/compiler/capnpc-capnp.c++
capnp/compiler/capnpc-capnp.c++
)
)
target_link_libraries
(
capnpc_capnp capnp kj
)
target_link_libraries
(
capnpc_capnp capnp kj
)
set_target_properties
(
capnpc_capnp PROPERTIES OUTPUT_NAME capnpc-capnp
)
set_target_properties
(
capnpc_capnp PROPERTIES OUTPUT_NAME capnpc-capnp
)
endif
()
# BUILD_TOOLS
# Install ==============================================================
# Install ==============================================================
export
(
TARGETS capnp capnp-tool capnp-rpc capnpc capnpc_cpp capnpc_capnp kj kj-async
if
(
BUILD_TOOLS
)
export
(
TARGETS capnp capnp-tool capnp-rpc capnpc capnpc_cpp capnpc_capnp kj kj-async
FILE
${
CMAKE_CURRENT_BINARY_DIR
}
/capnp-config.cmake
FILE
${
CMAKE_CURRENT_BINARY_DIR
}
/capnp-config.cmake
)
)
else
()
export
(
TARGETS capnp capnp-rpc capnpc kj kj-async
FILE
${
CMAKE_CURRENT_BINARY_DIR
}
/capnp-config.cmake
)
endif
()
export
(
PACKAGE capnp
)
export
(
PACKAGE capnp
)
install
(
TARGETS capnp capnp-tool capnp-rpc capnpc capnpc_cpp capnpc_capnp kj kj-async
if
(
BUILD_TOOLS
)
install
(
TARGETS capnp capnp-tool capnp-rpc capnpc capnpc_cpp capnpc_capnp kj kj-async
EXPORT capnp
EXPORT capnp
RUNTIME DESTINATION bin
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
ARCHIVE DESTINATION lib
)
)
# Symlink capnpc -> capnp
# Symlink capnpc -> capnp
install
(
CODE
"execute_process(COMMAND
\"
${
CMAKE_COMMAND
}
\"
-E create_symlink capnp
${
CMAKE_INSTALL_PREFIX
}
/bin/capnpc)"
)
install
(
CODE
"execute_process(COMMAND
\"
${
CMAKE_COMMAND
}
\"
-E create_symlink capnp
${
CMAKE_INSTALL_PREFIX
}
/bin/capnpc)"
)
else
()
install
(
TARGETS capnp capnp-rpc capnpc kj kj-async
EXPORT capnp
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endif
()
install
(
FILES
${
kj_headers
}
DESTINATION include/kj
)
install
(
FILES
${
kj_headers
}
DESTINATION include/kj
)
install
(
FILES
${
kj-async_headers
}
DESTINATION include/kj
)
install
(
FILES
${
kj-async_headers
}
DESTINATION include/kj
)
...
@@ -193,48 +209,73 @@ install(FILES ${capnpc_headers} DESTINATION include/capnp)
...
@@ -193,48 +209,73 @@ install(FILES ${capnpc_headers} DESTINATION include/capnp)
# Tests ==============================================================
# Tests ==============================================================
# Setup googletest build and library targets (gtest and gtest_main)
if
(
BUILD_TESTING
)
include
(
ExternalProject
)
# Setup googletest build and library targets (gtest and gtest_main)
ExternalProject_Add
(
gtest_build
include
(
ExternalProject
)
ExternalProject_Add
(
gtest_build
URL http://googletest.googlecode.com/files/gtest-1.7.0.zip
URL http://googletest.googlecode.com/files/gtest-1.7.0.zip
URL_HASH SHA1=f85f6d2481e2c6c4a18539e391aa4ea8ab0394af
URL_HASH SHA1=f85f6d2481e2c6c4a18539e391aa4ea8ab0394af
CMAKE_ARGS -DCMAKE_BUILD_TYPE=
${
CMAKE_BUILD_TYPE
}
CMAKE_ARGS -DCMAKE_BUILD_TYPE=
${
CMAKE_BUILD_TYPE
}
INSTALL_COMMAND
""
# Disable install
INSTALL_COMMAND
""
# Disable install
)
)
ExternalProject_Get_Property
(
gtest_build binary_dir
)
ExternalProject_Get_Property
(
gtest_build binary_dir
)
add_library
(
gtest UNKNOWN IMPORTED
)
add_library
(
gtest UNKNOWN IMPORTED
)
set_property
(
TARGET gtest
set_property
(
TARGET gtest
PROPERTY IMPORTED_LOCATION
${
binary_dir
}
/
${
CMAKE_FIND_LIBRARY_PREFIXES
}
gtest.a
PROPERTY IMPORTED_LOCATION
${
binary_dir
}
/
${
CMAKE_FIND_LIBRARY_PREFIXES
}
gtest.a
)
)
add_dependencies
(
gtest gtest_build
)
add_dependencies
(
gtest gtest_build
)
add_library
(
gtest_main UNKNOWN IMPORTED
)
add_library
(
gtest_main UNKNOWN IMPORTED
)
set_property
(
TARGET gtest_main
set_property
(
TARGET gtest_main
PROPERTY IMPORTED_LOCATION
${
binary_dir
}
/
${
CMAKE_FIND_LIBRARY_PREFIXES
}
gtest_main.a
PROPERTY IMPORTED_LOCATION
${
binary_dir
}
/
${
CMAKE_FIND_LIBRARY_PREFIXES
}
gtest_main.a
)
)
add_dependencies
(
gtest_main gtest
)
add_dependencies
(
gtest_main gtest
)
ExternalProject_Get_Property
(
gtest_build source_dir
)
ExternalProject_Get_Property
(
gtest_build source_dir
)
include_directories
(
${
source_dir
}
/include
)
include_directories
(
${
source_dir
}
/include
)
set
(
test_capnp_files
set
(
test_capnp_files
capnp/test.capnp
capnp/test.capnp
capnp/test-import.capnp
capnp/test-import.capnp
capnp/test-import2.capnp
capnp/test-import2.capnp
)
)
set
(
CAPNP_EXECUTABLE $<TARGET_FILE:capnp-tool>
)
# Setup paths to the schema compiler for generating ${test_capnp_files}
set
(
CAPNPC_CXX_EXECUTABLE $<TARGET_FILE:capnpc_cpp>
)
if
(
NOT EXTERNAL_CAPNP
)
set
(
CAPNPC_OUTPUT_DIR
${
CMAKE_CURRENT_BINARY_DIR
}
/test_capnp
)
set
(
CAPNP_EXECUTABLE $<TARGET_FILE:capnp-tool>
)
file
(
MAKE_DIRECTORY
${
CAPNPC_OUTPUT_DIR
}
)
set
(
CAPNPC_CXX_EXECUTABLE $<TARGET_FILE:capnpc_cpp>
)
else
()
capnp_generate_cpp
(
test_capnp_cpp_files test_capnp_h_files
${
test_capnp_files
}
)
# Allow paths to tools to be set with one of: (1) the CMake variables from the
# the FindCapnProto module; (2) environment variables; or (3) find_program()
include_directories
(
${
CAPNPC_OUTPUT_DIR
}
)
if
(
NOT CAPNP_EXECUTABLE
)
if
(
DEFINED ENV{CAPNP}
)
add_executable
(
capnp-tests
set
(
CAPNP_EXECUTABLE $ENV{CAPNP}
)
else
()
find_program
(
CAPNP_EXECUTABLE capnp
)
endif
()
endif
()
if
(
NOT CAPNPC_CXX_EXECUTABLE
)
if
(
DEFINED ENV{CAPNPC_CXX}
)
set
(
CAPNPC_CXX_EXECUTABLE $ENV{CAPNPC_CXX}
)
else
()
# Also search in the same directory that `capnp` was found in
get_filename_component
(
capnp_dir
${
CAPNP_EXECUTABLE
}
DIRECTORY
)
find_program
(
CAPNPC_CXX_EXECUTABLE capnpc-c++ HINTS
${
capnp_dir
}
)
endif
()
endif
()
endif
()
set
(
CAPNPC_OUTPUT_DIR
${
CMAKE_CURRENT_BINARY_DIR
}
/test_capnp
)
file
(
MAKE_DIRECTORY
${
CAPNPC_OUTPUT_DIR
}
)
capnp_generate_cpp
(
test_capnp_cpp_files test_capnp_h_files
${
test_capnp_files
}
)
include_directories
(
${
CAPNPC_OUTPUT_DIR
}
)
add_executable
(
capnp-tests
kj/common-test.c++
kj/common-test.c++
kj/memory-test.c++
kj/memory-test.c++
kj/refcount-test.c++
kj/refcount-test.c++
...
@@ -283,8 +324,8 @@ add_executable(capnp-tests
...
@@ -283,8 +324,8 @@ add_executable(capnp-tests
capnp/compiler/md5-test.c++
capnp/compiler/md5-test.c++
${
test_capnp_cpp_files
}
${
test_capnp_cpp_files
}
${
test_capnp_h_files
}
${
test_capnp_h_files
}
)
)
target_link_libraries
(
capnp-tests
target_link_libraries
(
capnp-tests
capnpc
capnpc
capnp-rpc
capnp-rpc
capnp
capnp
...
@@ -292,16 +333,17 @@ target_link_libraries(capnp-tests
...
@@ -292,16 +333,17 @@ target_link_libraries(capnp-tests
kj
kj
gtest
gtest
gtest_main
gtest_main
)
)
add_executable
(
capnp-evolution-tests capnp/compiler/evolution-test.c++
)
add_executable
(
capnp-evolution-tests capnp/compiler/evolution-test.c++
)
target_link_libraries
(
capnp-evolution-tests capnpc capnp kj
)
target_link_libraries
(
capnp-evolution-tests capnpc capnp kj
)
include
(
CTest
)
include
(
CTest
)
add_test
(
NAME capnp-tests-run COMMAND capnp-tests
)
add_test
(
NAME capnp-tests-run COMMAND capnp-tests
)
add_test
(
NAME capnp-evolution-tests-run COMMAND capnp-evolution-tests
)
add_test
(
NAME capnp-evolution-tests-run COMMAND capnp-evolution-tests
)
# Sadly, we can't use the 'test' target, as that's coopted by ctest
# Sadly, we can't use the 'test' target, as that's coopted by ctest
add_custom_target
(
check
${
CMAKE_CTEST_COMMAND
}
-V
)
add_custom_target
(
check
${
CMAKE_CTEST_COMMAND
}
-V
)
add_dependencies
(
check capnp-tests
)
add_dependencies
(
check capnp-tests
)
add_dependencies
(
check capnp-evolution-tests
)
add_dependencies
(
check capnp-evolution-tests
)
endif
()
# BUILD_TESTING
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