Skip to content

Commit

Permalink
Merge pull request #221 from ceeac/better-cmake-find
Browse files Browse the repository at this point in the history
Improvements to finding dependencies via cmake
  • Loading branch information
ceeac authored Apr 28, 2019
2 parents 679844b + 26d9418 commit 50add78
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 20 deletions.
31 changes: 30 additions & 1 deletion cmake-scripts/FindCapstone.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
#
# This module defines the following variables:
# Capstone_FOUND - true if Capstone was found
# Capstone_VERSION - Capstone library version
# Capstone_INCLUDE_DIRS - Include directories needed for Capstone
# Capstone_LIBRARIES - Libraries to link to when using Capstone
# Capstone_DLL - Path to Capstone DLL, if applicable
# Capstone_PDB - Path to Capstone PDB, if applicable

# Capstone_CSTOOL - Path to `cstool` executable, if present
#
# Additionally, this module defines the IMPORTED target Capstone::Capstone,
# if Capstone has been found.
#
Expand Down Expand Up @@ -48,15 +50,41 @@ if (WIN32)
PATHS /usr/local/bin /usr/bin/ $ENV{MINGDIR}/bin
)
endforeach ()
endif (WIN32)


# find cstool and extract version information, if available
find_program(Capstone_CSTOOL
NAMES cstool.exe cstool
PATHS /usr/local/bin /usr/bin/ $ENV{MINGDIR}/bin
)


if (Capstone_CSTOOL)
execute_process(COMMAND ${Capstone_CSTOOL} -v
OUTPUT_VARIABLE CSTOOL_OUTPUT
)

if (CSTOOL_OUTPUT MATCHES "v([0-9]+).([0-9]+).([0-9]+)")
set(Capstone_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
set(Capstone_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(Capstone_VERSION_MINOR "${CMAKE_MATCH_2}")
set(Capstone_VERSION_PATCH "${CMAKE_MATCH_3}")
endif ()
endif (Capstone_CSTOOL)


if (WIN32)
# Allow dll to be built without debug symbol support
find_package_handle_standard_args(Capstone
FOUND_VAR Capstone_FOUND
VERSION_VAR Capstone_VERSION
REQUIRED_VARS Capstone_LIBRARY Capstone_INCLUDE_DIR Capstone_DLL
)
else (WIN32)
find_package_handle_standard_args(Capstone
FOUND_VAR Capstone_FOUND
VERSION_VAR Capstone_VERSION
REQUIRED_VARS Capstone_LIBRARY Capstone_INCLUDE_DIR
)
endif (WIN32)
Expand All @@ -73,6 +101,7 @@ if (Capstone_FOUND OR NOT Capstone_FIND_REQUIRED)
Capstone_CONFIG
Capstone_INCLUDE_DIR
Capstone_LIBRARY
Capstone_CSTOOL
)

if (WIN32)
Expand Down
15 changes: 5 additions & 10 deletions cmake-scripts/boomerang-dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@
# WARRANTIES.
#

find_package(Qt5Core REQUIRED HINTS $ENV{QTDIR})
if (Qt5Core_FOUND)
mark_as_advanced(Qt5Core_DIR)
endif (Qt5Core_FOUND)

find_package(Qt5Xml REQUIRED HINTS $ENV{QTDIR})
if (Qt5Xml_FOUND)
mark_as_advanced(Qt5Xml_DIR)
endif (Qt5Xml_FOUND)
find_package(Qt5 COMPONENTS Core REQUIRED HINTS $ENV{QTDIR})
if (Qt5_FOUND)
mark_as_advanced(Qt5_DIR Qt5Core_DIR)
endif (Qt5_FOUND)

find_package(Threads)
find_package(Capstone 3.0 REQUIRED)
find_package(Capstone 3.0.5 REQUIRED)

find_package(FLEX 2.6 REQUIRED)
find_package(BISON 3.0 REQUIRED)
Expand Down
8 changes: 4 additions & 4 deletions cmake-scripts/boomerang-tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

if (BOOMERANG_BUILD_UNIT_TESTS)
enable_testing()
find_package(Qt5Test REQUIRED HINTS $ENV{QTDIR})
if (Qt5Test_FOUND)
mark_as_advanced(Qt5Test_DIR)
endif (Qt5Test_FOUND)
find_package(Qt5 COMPONENTS Test REQUIRED HINTS $ENV{QTDIR})
if (Qt5_FOUND)
mark_as_advanced(Qt5_DIR Qt5Test_DIR)
endif (Qt5_FOUND)

add_definitions(-DBOOMERANG_TEST_BASE="${BOOMERANG_OUTPUT_DIR}/")
add_subdirectory(${CMAKE_SOURCE_DIR}/tests/unit-tests)
Expand Down
5 changes: 4 additions & 1 deletion cmake-scripts/boomerang-windeployqt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

find_package(Qt5Core REQUIRED HINTS $ENV{QTDIR})
find_package(Qt5 COMPONENTS Core REQUIRED HINTS $ENV{QTDIR})
if (Qt5_FOUND)
mark_as_advanced(Qt5_DIR Qt5Core_DIR)
endif (Qt5_FOUND)

# Retrieve the absolute path to qmake and then use that path to find
# the windeployqt binary
Expand Down
8 changes: 4 additions & 4 deletions src/boomerang-gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@


set(CMAKE_AUTOMOC ON)
find_package(Qt5Widgets REQUIRED HINTS $ENV{QTDIR})
if (Qt5Widgets_FOUND)
mark_as_advanced(Qt5Widgets_DIR Qt5Gui_DIR)
endif(Qt5Widgets_FOUND)

find_package(Qt5 COMPONENTS Widgets Gui Xml REQUIRED HINTS $ENV{QTDIR})
if (Qt5_FOUND)
mark_as_advanced(Qt5_DIR Qt5Widgets_DIR Qt5Gui_DIR Qt5Xml_DIR)
endif (Qt5_FOUND)

set(gui_UI_FILES
About.ui
Expand Down

0 comments on commit 50add78

Please sign in to comment.