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

Minor problems with FindFlyCapture CMake module #17

Open
Algomorph opened this issue Dec 11, 2014 · 2 comments
Open

Minor problems with FindFlyCapture CMake module #17

Algomorph opened this issue Dec 11, 2014 · 2 comments

Comments

@Algomorph
Copy link

Sorry, I'm not using this library at all, I just pulled the FindFlyCapture.cmake module from it for use in my projects, so I'm too lazy to go through cloning this repo just to create a pull request or patch for this. I'm just going to paste the fixed file.

There are a couple of bugs I could find (so far). One is using "$ENV{SYSTEMDRIVE}" instead of "C:" for the drive letter. Another is missing the PATHS directive from the FIND_LIBRARY command (didn't work for me w/o it on CMake 3).

# Get default values for FLYCAPTURE_ROOT and FLYCAPTURE_LAYOUT

IF(WIN32)
  IF(EXISTS "$ENV{SYSTEMDRIVE}\\Program Files\\Point Grey Research\\FlyCapture2")
    SET(FLYCAPTURE_ROOT "$ENV{SYSTEMDRIVE}\\Program Files\\Point Grey Research\\FlyCapture2")
  ELSE(EXISTS "$ENV{SYSTEMDRIVE}\\Program Files\\Point Grey Research\\FlyCapture2")
    IF(EXISTS "$ENV{SYSTEMDRIVE}\\Program Files (x86)\\Point Grey Research\\FlyCapture2")
      # Maybe we're on 64bit but have 32bit SDK installed.
      SET(FLYCAPTURE_ROOT "$ENV{SYSTEMDRIVE}\\Program Files (x86)\\Point Grey Research\\FlyCapture2")
    ELSE(EXISTS "$ENV{SYSTEMDRIVE}\\Program Files (x86)\\Point Grey Research\\FlyCapture2")
      # If not, default to "C:\Program Files".
      SET(FLYCAPTURE_ROOT "$ENV{SYSTEMDRIVE}\\Program Files\\Point Grey Research\\FlyCapture2")
    ENDIF(EXISTS "$ENV{SYSTEMDRIVE}\\Program Files (x86)\\Point Grey Research\\FlyCapture2")
  ENDIF(EXISTS "$ENV{SYSTEMDRIVE}\\Program Files\\Point Grey Research\\FlyCapture2")
ELSE(WIN32)
  # Assume headers and libraries are installed in FHS locations
  SET(FLYCAPTURE_ROOT "/usr")
ENDIF(WIN32)


# defaults for FLYCAPTURE_LAYOUT
IF(WIN32)
  SET(FLYCAPTURE_LAYOUT "flycapture")
ELSE(WIN32)
  # Assume headers and libraries are installed in FHS locations
  SET(FLYCAPTURE_LAYOUT "FHS")
ENDIF(WIN32)

#############################################
# Environment variable overrides

SET(FLYCAPTURE_TEST_INCLUDE_PATHS "$ENV{FLYCAPTURE_TEST_INCLUDE_PATHS}")
IF(FLYCAPTURE_TEST_INCLUDE_PATHS STREQUAL "")
  # not set with env var, use defaults
  SET(FLYCAPTURE_TEST_INCLUDE_PATHS ${FLYCAPTURE_ROOT}/include)
ENDIF(FLYCAPTURE_TEST_INCLUDE_PATHS STREQUAL "")

# Prefer building 64 bit binaries on Windows. If you prefer building
#32 bit binaries on 64 bit machines, set this to FALSE.
SET(PREFER_64_BIT TRUE)


SET(FLYCAPTURE_TEST_LIB_PATHS "$ENV{FLYCAPTURE_TEST_LIB_PATHS}")
IF(FLYCAPTURE_TEST_LIB_PATHS STREQUAL "")
  # not set with env var, use defaults
  IF(FLYCAPTURE_LAYOUT STREQUAL "flycapture")
    IF(PREFER_64_BIT)
      IF(EXISTS ${FLYCAPTURE_ROOT}/lib64)
        SET(FLYCAPTURE_TEST_LIB_PATHS ${FLYCAPTURE_ROOT}/lib64)
        MESSAGE("building FlyCapture2 64-bit backend")
      ELSE(EXISTS ${FLYCAPTURE_ROOT}/lib64)
        SET(FLYCAPTURE_TEST_LIB_PATHS ${FLYCAPTURE_ROOT}/lib)
        MESSAGE("building FlyCapture2 32-bit backend")
      ENDIF(EXISTS ${FLYCAPTURE_ROOT}/lib64)
    ELSE(PREFER_64_BIT)
      IF(EXISTS ${FLYCAPTURE_ROOT}/lib)
        SET(FLYCAPTURE_TEST_LIB_PATHS ${FLYCAPTURE_ROOT}/lib)
        MESSAGE("building FlyCapture2 32-bit backend")
      ELSE(EXISTS ${FLYCAPTURE_ROOT}/lib)
        SET(FLYCAPTURE_TEST_LIB_PATHS ${FLYCAPTURE_ROOT}/lib64)
        MESSAGE("building FlyCapture2 64-bit backend")
      ENDIF(EXISTS ${FLYCAPTURE_ROOT}/lib)
    ENDIF(PREFER_64_BIT)
  ELSE(FLYCAPTURE_LAYOUT STREQUAL "flycapture")
    IF(NOT FLYCAPTURE_LAYOUT STREQUAL "FHS")
      MESSAGE(FATAL_ERROR "unknown FLYCAPTURE_LAYOUT " ${FLYCAPTURE_LAYOUT})
    ENDIF(NOT FLYCAPTURE_LAYOUT STREQUAL "FHS")
    SET(FLYCAPTURE_TEST_LIB_PATHS ${FLYCAPTURE_ROOT}/lib)
  ENDIF(FLYCAPTURE_LAYOUT STREQUAL "flycapture")
ENDIF(FLYCAPTURE_TEST_LIB_PATHS STREQUAL "")

#############################################
# No more environment variable settings

IF(NOT "$ENV{FLYCAPTURE_CMAKE_DEBUG}" STREQUAL "")
  MESSAGE("FLYCAPTURE_TEST_INCLUDE_PATHS " ${FLYCAPTURE_TEST_INCLUDE_PATHS})
  MESSAGE("FLYCAPTURE_TEST_LIB_PATHS " ${FLYCAPTURE_TEST_LIB_PATHS})
ENDIF(NOT "$ENV{FLYCAPTURE_CMAKE_DEBUG}" STREQUAL "")

FIND_PATH(FLYCAPTURE_INCLUDE_DIR 
    NAMES FlyCapture2.h
    HINTS ${FLYCAPTURE_TEST_INCLUDE_PATHS}
    PATH_SUFFIXES flycapture
)

FIND_LIBRARY(FLYCAPTURE_LIBRARY NAMES FlyCapture2 flycapture FlyCapture2.lib PATHS ${FLYCAPTURE_TEST_LIB_PATHS})

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLYCAPTURE DEFAULT_MSG
                                             FLYCAPTURE_INCLUDE_DIR
                                             FLYCAPTURE_LIBRARY)
SET(FLYCAPTURE_LIBRARIES ${FLYCAPTURE_LIBRARY})
SET(FLYCAPTURE_INCLUDE_DIRS ${FLYCAPTURE_INCLUDE_DIR})
@astraw
Copy link
Member

astraw commented Dec 13, 2014

Thanks for the notes. Just for reference, what version of CMake are you using?

@Algomorph
Copy link
Author

That was 3.0.2 on Windows 8.1, I believe. I've had no problems with the original code on Linux+CMake 2.8 so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants