Commit dd2430ce authored by Harris Hancock's avatar Harris Hancock Committed by Harris Hancock

cmake: Revise external capnp search logic

No change in behavior, but the comments needed updating, so I updated them.
Then I noticed a never-true if() case and removed it.
parent 647cea86
......@@ -4,33 +4,31 @@
if(BUILD_TESTING)
include(CTest)
if (EXTERNAL_CAPNP)
if(EXTERNAL_CAPNP)
# Setup CAPNP_GENERATE_CPP for compiling test schemas
find_package(CapnProto CONFIG QUIET)
if (NOT CapnProto_FOUND)
# Try and find the executables from an autotools-based installation
# Setup paths to the schema compiler for generating ${test_capnp_files}
if(NOT EXTERNAL_CAPNP AND NOT CAPNP_LITE)
set(CAPNP_EXECUTABLE $<TARGET_FILE:capnp_tool>)
set(CAPNPC_CXX_EXECUTABLE $<TARGET_FILE:capnpc_cpp>)
else()
# Allow paths to tools to be set with either environment variables or find_program()
if (NOT CAPNP_EXECUTABLE)
if (DEFINED ENV{CAPNP})
set(CAPNP_EXECUTABLE "$ENV{CAPNP}")
else()
find_program(CAPNP_EXECUTABLE capnp)
endif()
# No working installation of Cap'n Proto found, so fall back to searching the environment.
#
# We search for the external capnp compiler binaries via $CAPNP, $CAPNPC_CXX, and
# find_program(). find_program() will use various paths in its search, among them
# ${CMAKE_PREFIX_PATH}/bin and $PATH.
if (NOT CAPNP_EXECUTABLE)
if (DEFINED ENV{CAPNP})
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()
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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment