Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use FORCE_COMPILE_HRPSYSUTIL if you want to know whethere hrpsysUtils is build or not #1321

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 38 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include(FindPkgConfig)
include(CheckIncludeFiles)

option(ENABLE_INSTALL_RPATH "Enable RPATH setting for installed binary files" OFF)
option(USE_HRPSYSUTIL "Build hrpsysUtil" ON)
option(FORCE_COMPILE_HRPSYSUTIL "Try to build hrpsysUtil even if dependencies are missing" ON)
option(USE_IRRLICHT "Build Irrlicht components" OFF)
option(NO_DIGITAL_INPUT "Disable readDigitalInput and lengthDigitalInput" OFF)
option(USE_QPOASES "Build qpOASES" OFF)
Expand Down Expand Up @@ -142,30 +142,52 @@ include(CPack)
find_package(LibXml2 REQUIRED)
find_package(QuickHull REQUIRED)

if(USE_HRPSYSUTIL)
find_package(SDL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
pkg_check_modules(OpenCV opencv)
set(USE_HRPSYSUTIL ON)
find_package(SDL REQUIRED)
if (NOT SDL_FOUND)
message(WARNING "SDL is required to build hrpsysUtil")
set(USE_HRPSYSUTIL OFF)
endif()
find_package(OpenGL REQUIRED)
if (NOT OpenGL_FOUND)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (NOT OpenGL_FOUND)
if (NOT OPENGL_FOUND)

OpenGL_FOUNDではなくOPENGL_FOUNDに値がセットされるようです。

https://github.com/fkanehiro/hrpsys-base/pull/1310/files#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aL166

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think default behavior of find_packaeg(<package is to set <package>_FOUND
https://cmake.org/cmake/help/v3.0/command/find_package.html

but

$ cat CMakeLists.txt 
cmake_minimum_required(VERSION 2.4)
project(hrpsys)
find_package(OpenGL REQUIRED)
message("=> OpenGL_FOUND: ${OpenGL_FOUND}")
message("=> OPENGL_FOUND: ${OPENGL_FOUND}")

outputs

-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
=> OpenGL_FOUND: TRUE
=> OPENGL_FOUND: TRUE

???

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_package(OpenGL)をするとFindOpenGL.cmakeが実行されるのですが、

FindOpenGL.cmakeの中でFIND_PACKAGE_HANDLE_STANDARD_ARGS関数が呼ばれると、FIND_PACKAGE_HANDLE_STANDARD_ARGS関数の中でOpenGL_FOUNDとOPENGL_FOUND両方がセットされるようです。

ところが、cmake 2.4.7を使っているような古いPCでは、FindOpenGL.cmakeの中でFIND_PACKAGE_HANDLE_STANDARD_ARGSが呼ばれず、OPENGL_FOUNDだけを直接セットしているようです。

そのため、古いcmakeと今のcmake両方で動くようにするためには、OpenGL_FOUNDではなくOPENGL_FOUNDを使う必要があるのではないかと思います。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you. please create PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

お手数ですが上の僕のコメントの中でSuggested Changeの枠で表示されている内容についても、ブラウザ上でマウス操作でmergeできますので、取り入れていただけますでしょうか

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

message(WARNING "OpenGL is required to build hrpsysUtil")
set(USE_HRPSYSUTIL OFF)
endif()
find_package(GLUT REQUIRED)
if (NOT GLUT_FOUND)
message(WARNING "GLUT is required to build hrpsysUtil")
set(USE_HRPSYSUTIL OFF)
endif()
pkg_check_modules(OpenCV opencv)
if (NOT OpenCV_FOUND)
pkg_check_modules(OpenCV opencv-2.3.1)
if (NOT OpenCV_FOUND)
pkg_check_modules(OpenCV opencv-2.3.1)
pkg_check_modules(OpenCV opencv4)
if (NOT OpenCV_FOUND)
pkg_check_modules(OpenCV opencv4)
if (NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV is required to build hrpsysUtil")
message(WARNING "OpenCV is required to build hrpsysUtil")
set(USE_HRPSYSUTIL OFF)
endif()
endif()
endif()
include_directories(${OpenCV_INCLUDE_DIRS})
link_directories(${OpenCV_LIBRARY_DIRS})
pkg_check_modules(GLEW glew)
if (NOT GLEW_FOUND)
message(FATAL_ERROR "GLEW is required to build hrpsysUtil")
endif()
endif()
include_directories(${OpenCV_INCLUDE_DIRS})
link_directories(${OpenCV_LIBRARY_DIRS})
pkg_check_modules(GLEW glew)
if (NOT GLEW_FOUND)
message(WARNING "GLEW is required to build hrpsysUtil")
set(USE_HRPSYSUTIL OFF)
endif()

find_package(PCL)
if(USE_HRPSYSUTIL AND APPLE AND NOT PCL_FOUND)
message(FATAL_ERROR "PCL is required to build hrpsysUtil on Apple platform")
if(PCL_FOUND)
message(WARNING "PCL is required to build hrpsysUtil")
set(USE_HRPSYSUTIL OFF)
endif()

if(FORCE_COMPILE_HRPSYSUTIL AND (NOT USE_HRPSYSUTIL))
message(FATAL_ERROR "dependencies required to build hrpsysUtil is not found : SDL_FOUND: ${SDL_FOUND} / OpenGL_FOUND: ${OpenGL_FOUND} / GLUT_FOUND: ${GLUT_FOUND} / OpenCV_FOUND: ${OpenCV_FOUND} / GLEW_FOUND: ${GLEW_FOUND}")
k-okada marked this conversation as resolved.
Show resolved Hide resolved
endif()

execute_process(
Expand Down