Skip to content

Commit

Permalink
Add CMake support.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbalint13 committed Mar 20, 2018
1 parent bd20e1e commit 36cb912
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 1 deletion.
69 changes: 69 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#/* CMakeLists.txt */
#/* Project builder */

PROJECT(pba)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

IF(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0016 NEW)
ENDIF(COMMAND CMAKE_POLICY)

SET(CMAKE_SKIP_BUILD_RPATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)

SET(CMAKE_MODULE_PATH "cmake/;${CMAKE_MODULE_PATH}")

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

# Set a default build type if none was specified
IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
MESSAGE(STATUS "Setting build type to 'Release' as none was specified.")
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
ENDIF()

SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -O2 -mfpmath=sse -fPIC")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -O2 -mfpmath=sse -fPIC")

#SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -O2 -mfpmath=sse -fPIC -Wno-error=reorder -fpermissive -Wno-narrowing")
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -mfpmath=sse -fPIC -Wno-error=reorder -fpermissive -Wno-narrowing")

####
# find threads
find_package(Threads REQUIRED)
IF(CMAKE_USE_PTHREADS_INIT)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
ENDIF()

#####
# find CUDA
FIND_PACKAGE(CUDA QUIET)

IF(CUDA_FOUND)
ELSE()
ADD_DEFINITIONS(-DPBA_NO_GPU)
ENDIF()

OPTION(CPUPBA_USE_AVX "USE_AVX" ON)

if(CPUPBA_USE_AVX)
ADD_DEFINITIONS(-DCPUPBA_USE_AVX)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
endif()

ADD_SUBDIRECTORY(src/pba)
ADD_SUBDIRECTORY(src/driver)

INSTALL(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/pba
DESTINATION include/
COMPONENT headers
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h"
)
6 changes: 5 additions & 1 deletion History.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
1.0.5
1.0.6
Added CMakeFile
Fix compile warnings

1.0.5
Fixed a bug (rarely happens) in CUDA kernel configuration
* Symptom: ComputeJtE<Point>: invalid configuration argument(9)
Triggers when npoint is within (2 * n * 65505 ~ 2 * n * 65535) for n >= 2
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# pba
Parralel Bundle Adjustment


* This is clean code derived from http://grail.cs.washington.edu/projects/mcba/ (v1.0.5)

Some Changes:

- CMake infrastructure.
- Fixed AVX2 for GCC / Linux.
- No compile warns, clean code.
7 changes: 7 additions & 0 deletions src/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

ADD_EXECUTABLE(pba_driver driver.cpp)

TARGET_LINK_LIBRARIES(pba_driver pba ${CMAKE_THREAD_LIBS_INIT})

INSTALL(TARGETS pba_driver DESTINATION "/usr/bin/")

37 changes: 37 additions & 0 deletions src/pba/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@


IF(CUDA_FOUND)

INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})

CUDA_COMPILE(PROGRAM_CU ProgramCU.cu)

SET(SRCS pba.cpp
ConfigBA.cpp
CuTexImage.cpp
SparseBundleCPU.cpp
SparseBundleCU.cpp)

CUDA_ADD_LIBRARY(pba SHARED ${SRCS} ${PROGRAM_CU} ${CUDA_LIBRARY})

TARGET_LINK_LIBRARIES(pba ${CMAKE_THREAD_LIBS_INIT})

SET_TARGET_PROPERTIES(pba PROPERTIES
SOVERSION 1
VERSION 1.5.0)
ELSE()

SET(SRCS pba.cpp
ConfigBA.cpp
SparseBundleCPU.cpp)

ADD_LIBRARY(pba SHARED ${SRCS})

SET_TARGET_PROPERTIES(pba PROPERTIES
SOVERSION 1
VERSION 1.5.0)
TARGET_LINK_LIBRARIES(pba ${CMAKE_THREAD_LIBS_INIT})

ENDIF()

INSTALL(TARGETS pba DESTINATION "lib${LIB_SUFFIX}")

0 comments on commit 36cb912

Please sign in to comment.