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

Multi-platform build with CMake #1

Open
wants to merge 15 commits 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
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@

src_c/homemakefile

[Dd]ebug/
[Rr]elease/
ipch/
*.sdf
*.suo
*.exe
*.ilk
*.pdb
*.pdb
build/
39 changes: 39 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Main CMakeLists file
cmake_minimum_required (VERSION 2.8)

project (3dptv_solution)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
# Add definitions and Find TIFF

if (WIN32)
add_definitions( -D_CONSOLE -D_CRT_SECURE_NO_WARNINGS )
set(TIFF_LIBRARY "${CMAKE_SOURCE_DIR}/src_c/libtiff.lib")
else()
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/opt/ActiveTcl-8.6")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/lib")
find_package( TIFF REQUIRED )
endif()

# Find TCL/TK
find_package( TCL REQUIRED 8.6)

if (TCLTK_FOUND )
message(STATUS "TCL INCLUDE: " ${TCL_INCLUDE_PATH})
message(STATUS "TCL LIB: " ${TCL_LIBRARY})
message(STATUS "TK INCLUDE: " ${TCL_INCLUDE_PATH})
message(STATUS "TK LIB: " ${TK_LIBRARY})
link_directories( ${TCL_LIBRARY} ${TK_LIBRARY} )
include_directories( ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH} )
endif()

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")

message(STATUS "gathering ptv tcl files:")
file(GLOB ptv_tcl "${CMAKE_SOURCE_DIR}/src_tcl/*.tcl")

add_subdirectory("${CMAKE_SOURCE_DIR}/src_c")
49 changes: 0 additions & 49 deletions INSTALL.rst

This file was deleted.

15 changes: 0 additions & 15 deletions README

This file was deleted.

67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
## If you want to use the source code and contribute to the project:

1. Fork this repository to your account, using the Fork button
2. create branch or fix the master branch if you feel confident enough
3. send us the pull request when you feel like ready to submit your branch or your master into the community branch



## Multi-platform build using CMake

1. Download and install CMake (version 2.8 or higher)

http://www.cmake.org/cmake/resources/software.html

2. Download and install ActiveTCL 8.6 for the desired platform

http://www.activestate.com/activetcl/downloads

3. Download and install libtiff (*nix and OSX systems)

-- on Ubuntu run the following in a terminal:

sudo apt-get install build-essential
sudo apt-get install libtiff-dev

-- on Mac OS X is recommended to install libtiff using Homebrew:

brew install libtiff

4. Create a build directory inside the main 3dptv directory (```3dptv/build```)


5. Run CMake and generate the project or make files

a. start the ```cmake-gui``` from the desktop shortcut or program list

-- alternatively run the following from command line

cd 3dptv/build
cmake-gui ../

b. browse for the source directory: ```3dptv/```

c. browse for the build directory just created: ```3dptv/build/```

d. click ```configure``` and select the build type and compiler

--on Mac OS X choose the following options: UNIX makefiles, native compilers

--on Windows choose Visual Studio 2010 or 2008 (32-bit supported currently)

--on *nix systems choose Unix make files or alternatively use Eclipse CTD and unix make files

Note: if an error occurs saying that libtiff or ActiveTCL cannot be found
click on the entry in the "value" column and browse for the libraries' "include" directories and ".lib" files
click ```configure``` again to locate the libraries. If any rows appear red, click configure until no rows are highlighted.

e. click generate to create the project or make files

6. Run Visual Studio and open the solution file in ```3dptv/build/``` or run make from within the build directory to compile the code.

--The executable will be generated and placed inside ```3dptv/build/bin/```

7. Run the software from the ```test``` folder with a link to ```ptv.tcl``` as an input:

cd 3dptv/test
../build/bin/3dptv ../ptv.tcl
125 changes: 0 additions & 125 deletions install_nix.md

This file was deleted.

69 changes: 69 additions & 0 deletions src_c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This is the 3dptv/src_c CMakeLists.txt file

message(STATUS "gathering ptv project files from 3dptv/src_c/:")

set(TARGET_NAME "3dptv")

# gather the header files

file ( GLOB ptv_hdrs
globals.h
ptv.h
tcl.h
tiff.h
tiffio.h
tiffvers.h
tk.h
typedefs.h
)

# gather the source files

file ( GLOB ptv_srcs
change_parameter.c
checkpoints.c
correspondences.c
demo.c
draw.c
epi.c
image_processing.c
imgcoord.c
intersect.c
jw_ImgFmtTIF.c
jw_main.c
jw_ptv.c
lsqadj.c
mousefunction.c
multimed.c
orientation.c
peakfitting.c
pointpos.c
ptv.c
ray_tracing.c
resource1.h
resource2.h
rotation.c
segmentation.c
sortgrid.c
tools.c
track.c
trafo.c
ttools.c
vrml.c
)

# organize the files into folders inside the project

source_group("Header Files" FILES ${ptv_hdrs})
source_group("Source Files" FILES ${ptv_srcs})
source_group("Tcl Files" FILES ${ptv_tcl})

add_executable(${TARGET_NAME} ${ptv_srcs} ${ptv_hdrs} ${ptv_tcl} )

if(WIN32)
set_target_properties(${TARGET_NAME} PROPERTIES LINKER_LANGUAGE C)
set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc")
endif()

set(EXTRA_LIBS ${EXTRA_LIBS} ${TCL_LIBRARY} ${TK_LIBRARY} ${TIFF_LIBRARY})
target_link_libraries(${TARGET_NAME} ${EXTRA_LIBS} )
2 changes: 1 addition & 1 deletion src_c/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void sortgrid_file (Tcl_Interp* interp, Exterior Ex, Interior I, Glass G, ap_52
// --- tools.c ---
void write_ori (Exterior Ex, Interior I, Glass G, char filename[64]);
int read_ori (Exterior *Ex, Interior *I, Glass *G, char filename[64]);
FILE *fopen_r (CHAR filename[256]);
FILE *fopen_r (char filename[256]);
FILE *fopen_rp (char *filename);
int read_image (Tcl_Interp* interp, char path[128], unsigned char *img);
int write_tiff (const char path[256], unsigned char *data, int nx, int ny);
Expand Down
Loading