You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FindThirdPartyEmotivAPI.cmake 4.0KB

3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # ---------------------------------
  2. # Finds Emotiv SDK
  3. # Adds library to target
  4. # Adds include path
  5. # ---------------------------------
  6. GET_PROPERTY(OV_PRINTED GLOBAL PROPERTY OV_TRIED_ThirdPartyEmotivAPI)
  7. IF(WIN32)
  8. IF("${PLATFORM_TARGET}" STREQUAL "x64")
  9. OV_PRINT(OV_PRINTED " SKIPPED Emotiv EPOC not yet supported on 64bit builds...")
  10. SET_PROPERTY(GLOBAL PROPERTY OV_TRIED_ThirdPartyEmotivAPI "Yes")
  11. RETURN()
  12. ENDIF()
  13. ENDIF()
  14. # Put the path to the Emotiv SDK followed by *
  15. FILE(GLOB PATH_Candidates
  16. "C:/Program Files/Emotiv Development Kit*"
  17. "C:/Program Files/Emotiv Research Edition*"
  18. "C:/Program Files/Emotiv SDK Premium Edition*"
  19. "C:/Program Files (x86)/Emotiv Development Kit*"
  20. "C:/Program Files (x86)/Emotiv Research Edition*"
  21. "C:/Program Files (x86)/Emotiv SDK Premium Edition*"
  22. "/home/{username}/EmotivResearch_2.0.0.20*"
  23. #Put here the path to the directory where you installed the emotiv sdk
  24. )
  25. FOREACH(Candidate_folder ${PATH_Candidates})
  26. # OV_PRINT(OV_PRINTED "Found path ${PATH_Candidate}")
  27. #Version 1 of sdk
  28. LIST(APPEND PATH_Candidates ${Candidate_folder}/doc/examples/include)
  29. #Version 2 of sdk
  30. LIST(APPEND PATH_Candidates ${Candidate_folder}/doc/examples_Qt/example5)
  31. #Version 3 of sdk
  32. LIST(APPEND PATH_Candidates ${Candidate_folder}/EDK/Header\ files/)
  33. ENDFOREACH(Candidate_folder ${PATH_Candidates})
  34. SET(PATH_EmotivAPI "-NOTFOUND")
  35. FIND_PATH(PATH_EmotivAPI1 edk.h PATHS ${PATH_Candidates} ${LIST_DEPENDENCIES_PATH})
  36. IF(PATH_EmotivAPI1)
  37. OV_PRINT(OV_PRINTED " Found Emotiv Research API 1.x ...")
  38. SET(OV_EMOTIV_VERSION "research-1")
  39. SET(PATH_EmotivAPI ${PATH_EmotivAPI1})
  40. SET(OV_EMOTIV_PATHS "${PATH_EmotivAPI}/../lib" "${PATH_EmotivAPI}/../../lib" "${PATH_EmotivAPI}/../../../lib")
  41. ENDIF(PATH_EmotivAPI1)
  42. FIND_PATH(PATH_EmotivAPI2 IEdk.h PATHS ${PATH_Candidates} ${LIST_DEPENDENCIES_PATH})
  43. IF(PATH_EmotivAPI2)
  44. OV_PRINT(OV_PRINTED " Found Emotiv API 3.x ...")
  45. SET(OV_EMOTIV_VERSION "community")
  46. SET(PATH_EmotivAPI ${PATH_EmotivAPI2})
  47. SET(OV_EMOTIV_PATHS "${PATH_EmotivAPI}/../x86" "${PATH_EmotivAPI}/../../x86" "${PATH_EmotivAPI}/../../../x86")
  48. ENDIF(PATH_EmotivAPI2)
  49. FIND_PATH(PATH_EmotivAPI3 IEegData.h PATHS ${PATH_Candidates} ${LIST_DEPENDENCIES_PATH})
  50. IF(PATH_EmotivAPI3)
  51. OV_PRINT(OV_PRINTED " Found Emotiv Research API 3.x ...")
  52. SET(OV_EMOTIV_VERSION "research-3")
  53. SET(PATH_EmotivAPI ${PATH_EmotivAPI3})
  54. SET(OV_EMOTIV_PATHS "${PATH_EmotivAPI}/../x86" "${PATH_EmotivAPI}/../../x86" "${PATH_EmotivAPI}/../../../x86")
  55. ENDIF(PATH_EmotivAPI3)
  56. IF(PATH_EmotivAPI)
  57. FIND_LIBRARY(LIB_EmotivAPI edk PATHS ${OV_EMOTIV_PATHS})
  58. IF(LIB_EmotivAPI)
  59. OV_PRINT(OV_PRINTED " [ OK ] api ${PATH_EmotivAPI}")
  60. OV_PRINT(OV_PRINTED " [ OK ] lib ${LIB_EmotivAPI}")
  61. INCLUDE_DIRECTORIES(${PATH_EmotivAPI})
  62. TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_EmotivAPI} )
  63. IF(WIN32)
  64. # To delay load EDK.dll and redistribute binary
  65. TARGET_LINK_LIBRARIES(${PROJECT_NAME} Delayimp.lib )
  66. SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DELAYLOAD:edk.dll /DELAY:UNLOAD")
  67. ENDIF(WIN32)
  68. IF(${OV_EMOTIV_VERSION} STREQUAL "community")
  69. # This doesn't work by itself yet...
  70. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyEmotivCommunityAPI)
  71. ELSEIF(${OV_EMOTIV_VERSION} STREQUAL "research-1")
  72. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyEmotivAPI)
  73. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyEmotivResearchAPI1x)
  74. ELSEIF(${OV_EMOTIV_VERSION} STREQUAL "research-3")
  75. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyEmotivAPI)
  76. ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyEmotivResearchAPI3x)
  77. ENDIF(${OV_EMOTIV_VERSION} STREQUAL "community")
  78. ELSE(LIB_EmotivAPI)
  79. OV_PRINT(OV_PRINTED " [FAILED] lib Emotiv edk.lib")
  80. ENDIF(LIB_EmotivAPI)
  81. ELSE(PATH_EmotivAPI)
  82. OV_PRINT(OV_PRINTED " FAILED to find Emotiv API (optional driver)")
  83. ENDIF(PATH_EmotivAPI)
  84. SET_PROPERTY(GLOBAL PROPERTY OV_TRIED_ThirdPartyEmotivAPI "Yes")