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

add cmake build #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
46 changes: 46 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)

SET(CMAKE_BUILD_TYPE Debug CACHE STRING "Default Build Type")

PROJECT (phpspy)

ADD_CUSTOM_TARGET(submodules
COMMAND git submodule update --init --remote --recursive)

ADD_CUSTOM_TARGET(libtermbox
COMMAND ${PROJECT_SOURCE_DIR}/vendor/termbox/waf configure --prefix=${PROJECT_BUILD_DIR}
COMMAND ${PROJECT_SOURCE_DIR}/vendor/termbox/waf --targets=termbox_static
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/vendor/termbox
DEPENDS submodules)

INCLUDE_DIRECTORIES(.)
INCLUDE_DIRECTORIES(vendor)
INCLUDE_DIRECTORIES(vendor/termbox/src)

ADD_EXECUTABLE (phpspy phpspy.c pgrep.c top.c addr_objdump.c event_fout.c)
ADD_DEPENDENCIES (phpspy libtermbox)

TARGET_LINK_LIBRARIES (phpspy pthread ${PROJECT_SOURCE_DIR}/vendor/termbox/build/src/libtermbox.a)

INSTALL (TARGETS phpspy
RUNTIME DESTINATION bin)

INSTALL (FILES ${PROJECT_SOURCE_DIR}/phpspy.h
DESTINATION include/phpspy)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/php_structs_70.h
DESTINATION include/phpspy)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/php_structs_71.h
DESTINATION include/phpspy)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/php_structs_72.h
DESTINATION include/phpspy)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/php_structs_73.h
DESTINATION include/phpspy)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/php_structs_74.h
DESTINATION include/phpspy)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/vendor/uthash.h
DESTINATION include/phpspy)

SET_TARGET_PROPERTIES(phpspy PROPERTIES
COMPILE_FLAGS "-std=c99 -Wall -Werror"
)

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ All with no changes to your application and minimal overhead.
$ make phpspy_dynamic # Dynamically link dependencies
$ # or
$ USE_ZEND=1 make ... # Use Zend structs instead of built-in structs (requires php-dev or php-devel)

### CMake Build

The CMake will update submodules and create a build of phpspy statically linked to libtermbox:

$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release
$ make -j4 install

CMake Options:

* `CMAKE_BUILD_TYPE` may be `Release` or `Debug`
* `CMAKE_INSTALL_PREFIX` will set install prefix

### Usage
$ ./phpspy -h
Expand Down