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 CMakeLists.txt to build lib/ bin/ with cmake #124

Open
wants to merge 1 commit into
base: unstable
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ bin/*.samples
bin/*.png
bin/*.tex
bin/*.txt
!bin/CMakeLists.txt
bin/*.dat
bin/*.bin
bin/*.json
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.6)

set(ccv_lib "ccv_lib")
set(ccv_bin "ccv_bin")

set(CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG} -g -O0)
set(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} -O2)

add_subdirectory(lib)
add_subdirectory(bin)

19 changes: 19 additions & 0 deletions bin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 2.6)

project(${ccv_bin})

set(exes aflw bbfcreate bbfdetect bbffmt cifar-10 cnnclassify dpmcreate dpmdetect icfcreate icfdetect icfoptimize image-net msermatch scdcreate scddetect siftmatch swtcreate swtdetect tld)

foreach(e ${exes})
file(GLOB sources "${e}.c")

add_executable(${e} ${sources})
set_target_properties(${e} PROPERTIES OUTPUT_NAME ${e})

add_dependencies(${e} ${ccv_lib})
include_directories(${ccv_lib_SOURCE_DIR})
target_link_libraries(${e} ${ccv_lib})

install(TARGETS ${e} DESTINATION bin)
endforeach()

54 changes: 54 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 2.6)

project(${ccv_lib})

file(GLOB sources "*.c")
file(GLOB_RECURSE thirdparty "3rdparty/*.c")
file(GLOB_RECURSE cuda "cuda/*.c")

file(GLOB header "ccv.h")

set(DEP_LIBS m dl pthread)

find_package(PNG REQUIRED)
find_package(JPEG REQUIRED)

if(PNG_FOUND)
add_definitions(-DHAVE_LIBPNG)
list(APPEND DEP_LIBS png)
endif()

if(JPEG_FOUND)
add_definitions(-DHAVE_LIBJPEG)
list(APPEND DEP_LIBS jpeg)
endif()

find_library(LIBLINEAR_LIBRARY NAMES linear liblinear)

if(LIBLINEAR_LIBRARY)
message("liblinear found")
add_definitions(-DHAVE_LIBLINEAR)
list(APPEND DEP_LIBS linear)
else()
message("liblinear not found")
endif()

find_library(LIBGSL_LIBRARY NAMES gsl libgsl)

if(LIBGSL_LIBRARY)
message("libgsl found")
add_definitions(-DHAVE_GSL)
list(APPEND DEP_LIBS gsl)
else()
message("libgsl not found")
endif()

message("libs: ${DEP_LIBS}")

add_library(${ccv_lib} SHARED ${sources} ${thirdparty} ${cuda})
set_target_properties(${ccv_lib} PROPERTIES OUTPUT_NAME "ccv")
target_link_libraries(${ccv_lib} ${DEP_LIBS})

install(TARGETS ${ccv_lib} DESTINATION lib)
install(FILES ${header} DESTINATION "include")