iutest icon indicating copy to clipboard operation
iutest copied to clipboard

cmake: FindIutest

Open yumetodo opened this issue 6 years ago • 7 comments

まあincludeするだけのライブラリだけれども、

# - Try to find iutest include dirs
#
# Usage of this module as follows:
#
#     find_package(IUTEST)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
#  IUTEST_ROOT_DIR          Set this variable to the root installation of
#                            iutest if the module has problems finding the
#                            proper installation path.
#
# Variables defined by this module:
#
#  IUTEST_FOUND             System has iutest, include dirs found
#  IUTEST_INCLUDE_DIR       The iutest include directories.

find_path(IUTEST_ROOT_DIR
        NAMES include/iutest.hpp
        )

find_path(IUTEST_INCLUDE_DIR
        NAMES iutest.hpp
        HINTS ${IUTEST_ROOT_DIR}/include
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(IUTEST DEFAULT_MSG
    IUTEST_INCLUDE_DIR
)

のようなスクリプトがあると使いやすいと思うんですが、どうでしょうか?

yumetodo avatar Jan 28 '18 11:01 yumetodo

とりあえず追加してみたのですが、やり方間違えたらご指摘ください

srz-zumix avatar Feb 27 '18 03:02 srz-zumix

このIssue立ててから気がついたのですが、<foo>-config.cmake を作ってFIndXXX.cmakeを作るなみたいなWarningが出ますね。私にはどうすればいいのかさっぱりですが。

yumetodo avatar Mar 03 '18 00:03 yumetodo

CMake Error at CMakeLists.txt:34 (find_package):
  By not providing "FindIUTEST.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "IUTEST", but
  CMake did not find one.
  Could not find a package configuration file provided by "IUTEST" with any
  of the following names:
    IUTESTConfig.cmake
    iutest-config.cmake
  Add the installation prefix of "IUTEST" to CMAKE_PREFIX_PATH or set
  "IUTEST_DIR" to a directory containing one of the above files.  If "IUTEST"
  provides a separate development package or SDK, be sure it has been
  installed.

真剣に向き合うときが来たようだ

srz-zumix avatar Nov 22 '18 07:11 srz-zumix

やっぱりxxx-config.cmakeを生成させるようにしなければならないか。

yumetodo avatar Nov 22 '18 08:11 yumetodo

お手軽な xxx-config.cmake の作成方法 https://qiita.com/osamu0329/items/134de918c0ffa7f0557b

yumetodo avatar Nov 22 '18 08:11 yumetodo

[CMake] ライブラリを自動的に探すFind.cmakeのテンプレート - Qiitaより

今気づいたんですが、iutestはヘッダーのみで、かつこのプロジェクトのライブラリですよね? find_packageを使わず、Microsoft/GSLのようにadd_libraryを使えばいいような気が…

add_library(IUTEST INTERFACE)
target_include_directories(IUTEST
  INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
  )

yumetodo avatar Nov 28 '18 07:11 yumetodo

なるほど。INTERFACE ってのがあるんですね。 やってみます 👍

srz-zumix avatar Nov 28 '18 07:11 srz-zumix