From d93b37b6d6501ea03ad82a30e95aec8c2655226e Mon Sep 17 00:00:00 2001 From: petasis Date: Fri, 25 Aug 2017 11:10:11 +0300 Subject: Added -Dwith-tcl= to CMake --- CMakeLists.txt | 59 ++++++++++++++++++++++++++++++++++++++-------------------- Changelog | 3 +++ README.cmake | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ win/OleDND.h | 8 ++++---- 4 files changed, 96 insertions(+), 24 deletions(-) create mode 100644 README.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1844e9b..772941a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,4 @@ -CMAKE_MINIMUM_REQUIRED ( VERSION 2.6 ) -IF ( POLICY CMP0042 ) - CMAKE_POLICY ( SET CMP0042 NEW ) -ENDIF ( POLICY CMP0042 ) - -## Ensure that the variable PKG_OS_ARCH exists! If undefined, define it with -## the value "x86_32" -IF ( NOT PKG_OS_ARCH ) - SET ( PKG_OS_ARCH x86_32 ) -ENDIF ( NOT PKG_OS_ARCH ) - -## =========================================================================== -## No need to modify below this point! -## =========================================================================== - -SET ( NO_MSVCRT ON ) +CMAKE_MINIMUM_REQUIRED ( VERSION 3.2 FATAL_ERROR ) ## =========================================================================== ## Project Information @@ -28,6 +13,28 @@ SET ( PKG_BUILD_VERSION 0 ) SET ( PKG_VENDOR "Georgios Petasis" ) ## =========================================================================== +## User options... +## =========================================================================== +set(with-tclsh "" CACHE FILEPATH "location of a working tclsh executable") +set(with-tcl "" CACHE PATH "directory containing tcl configuration (tclConfig.sh)") + +## Ensure that the variable PKG_OS_ARCH exists! If undefined, define it with +## the value "x86_32" +IF ( NOT PKG_OS_ARCH ) + SET ( PKG_OS_ARCH x86_32 ) +ENDIF ( NOT PKG_OS_ARCH ) + +IF ( POLICY CMP0042 ) + CMAKE_POLICY ( SET CMP0042 NEW ) +ENDIF ( POLICY CMP0042 ) + +## =========================================================================== +## No need to modify below this point! +## =========================================================================== + +SET ( NO_MSVCRT ON ) + +## =========================================================================== ## Project sources ## =========================================================================== IF ( WIN32 ) @@ -125,18 +132,30 @@ SET ( CP ${CMAKE_COMMAND} -E copy ) ## Locate Tcl/Tk ## =========================================================================== MESSAGE ( STATUS "Searching for Tcl/Tk..." ) +if (NOT "${with-tcl}" STREQUAL "") + MESSAGE ( STATUS " Tcl lib directory manually set by -Dwith-tcl=" ${with-tcl} ) + get_filename_component(TKDND_TCL_ROOT "${with-tcl}" DIRECTORY) + MESSAGE ( STATUS " Setting Tcl root to: " ${TKDND_TCL_ROOT} ) + set ( CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${TKDND_TCL_ROOT} ) + set (TCL_ROOT ${TKDND_TCL_ROOT}) + set (TclStub_ROOT ${TKDND_TCL_ROOT}) +endif () +if (NOT "${with-tclsh}" STREQUAL "") + MESSAGE ( STATUS " Tclsh manually set by -Dwith-tclsh=" ${with-tclsh} ) + set (TCL_TCLSH ${with-tclsh}) +endif () FIND_PACKAGE ( TCL REQUIRED ) FIND_PACKAGE ( TclStub REQUIRED ) ## Tcl/Tk info (useful for debug purposes)... -# MESSAGE ( STATUS " TCL_TCLSH: " ${TCL_TCLSH} ) + MESSAGE ( STATUS " TCL_TCLSH: " ${TCL_TCLSH} ) MESSAGE ( STATUS " TCL_INCLUDE_PATH: " ${TCL_INCLUDE_PATH} ) MESSAGE ( STATUS " TCL_STUB_LIBRARY: " ${TCL_STUB_LIBRARY} ) -# MESSAGE ( STATUS " TCL_LIBRARY: " ${TCL_LIBRARY} ) -# MESSAGE ( STATUS " TK_WISH: " ${TK_WISH} ) + MESSAGE ( STATUS " TCL_LIBRARY: " ${TCL_LIBRARY} ) + MESSAGE ( STATUS " TK_WISH: " ${TK_WISH} ) MESSAGE ( STATUS " TK_INCLUDE_PATH: " ${TK_INCLUDE_PATH} ) MESSAGE ( STATUS " TK_STUB_LIBRARY: " ${TK_STUB_LIBRARY} ) -# MESSAGE ( STATUS " TK_LIBRARY: " ${TK_LIBRARY} ) + MESSAGE ( STATUS " TK_LIBRARY: " ${TK_LIBRARY} ) ## Enable Tcl/Tk stubs globally... ADD_DEFINITIONS ( -DUSE_TCL_STUBS ) diff --git a/Changelog b/Changelog index c965bad..1915bb6 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +2017-08-25 Petasis George + * CMakeLists.txt: Added support for -Dwith-tcl, -Dwith-tclsh. + 2017-01-25 Petasis George * win\OleDND.cpp: Fixed a memory leak on the pDropTarget object in TkDND_RegisterDragDropObjCmd. Added calls to RevokeDragDrop on window diff --git a/README.cmake b/README.cmake new file mode 100644 index 0000000..087537e --- /dev/null +++ b/README.cmake @@ -0,0 +1,50 @@ +In order to build Rivet with cmake, the following software is required: + +a) cmake, version 3.2 or newer. + +Compiling Rivet with cmake: +------------------------------------------------------- + +1) Change the working directory to "cmake". + +2) Execute the following commands (all commands must be executed from the + "cmake" directory): + + cmake -E make_directory build + cmake -E chdir build cmake .. + cmake --build build --target all --clean-first + cmake --build build --target install + +3) To install mod_rivet.so/Rivet library to a custom location, + the following commands can be used: + + cmake -E make_directory build + cmake -E chdir build cmake \ + -DAPACHE_MODULE_DIR=/home/tcl/rivet/branches/cmake/cmake/test/modules \ + -DAPACHE_LIB_DIR=/home/tcl/rivet/branches/cmake/cmake/test/ .. + cmake --build build --config Release --target install + +4) To install mod_rivet.so/Rivet library in a system where Apache Server is not + in a known location (i.e. under Windows), you can speficy APACHE_ROOT: + + cmake -E make_directory build + cmake -E chdir build cmake -DAPACHE_ROOT=G:/Apache24 .. + cmake --build build --config Release --target install + +5) Compile for 64 bits under Windows (for Visual Studio 2017): + + cmake -E make_directory build_64 + cmake -E chdir build_64 cmake -DAPACHE_ROOT=G:/Apache24 -G "Visual Studio 15 2017 Win64" .. + cmake --build build_64 --config Release --target install + + -G "..." can be set to any of the available 64-bit generators available under + the platform. + +6) Specify Tcl at a non standard location: + + cmake -E make_directory build_64 + cmake -E chdir build_64 cmake -DAPACHE_ROOT=G:/Apache24 -G "Visual Studio 15 2017 Win64" -Dwith-tcl=C:/TclApps/Tcl64/lib .. + cmake --build build_64 --config Release --target install + + Instead of -Dwith-tcl=, -DTCL_ROOT=, -DTclStub_ROOT, and -DTCL_TCLSH= can be + specified as an alternative. diff --git a/win/OleDND.h b/win/OleDND.h index f194c6e..efbbf34 100644 --- a/win/OleDND.h +++ b/win/OleDND.h @@ -447,7 +447,7 @@ private: }; /* LookupFormatEtc */ HGLOBAL DupGlobalMem(HGLOBAL hMem) { - DWORD len = GlobalSize(hMem); + SIZE_T len = GlobalSize(hMem); PVOID source = GlobalLock(hMem); PVOID dest = GlobalAlloc(GMEM_FIXED, len); memcpy(dest, source, len); @@ -910,7 +910,7 @@ private: Tcl_NewStringObj("unsupported type", -1); } bytes = (unsigned char *) GlobalLock(StgMed.hGlobal); - result = Tcl_NewByteArrayObj(bytes, GlobalSize(StgMed.hGlobal)); + result = Tcl_NewByteArrayObj(bytes, (int) GlobalSize(StgMed.hGlobal)); GlobalUnlock(StgMed.hGlobal); ReleaseStgMedium(&StgMed); return result; @@ -1260,7 +1260,7 @@ private: Tcl_Obj *GetData_UniformResourceLocator(IDataObject *pDataObject) { STGMEDIUM StgMed; - FORMATETC fmte = { + FORMATETC fmte = { (CLIPFORMAT) RegisterClipboardFormat( _TEXT("UniformResourceLocator") ), (DVTARGETDEVICE FAR *)NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; @@ -1294,7 +1294,7 @@ private: Tcl_Obj *GetData_UniformResourceLocatorW(IDataObject *pDataObject) { STGMEDIUM StgMed; - FORMATETC fmte = { + FORMATETC fmte = { (CLIPFORMAT) RegisterClipboardFormat( _TEXT("UniformResourceLocatorW") ), (DVTARGETDEVICE FAR *)NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; -- cgit v0.12