Permalink
Browse files

Some fixes on CMakeLists

  • Loading branch information...
1 parent ad8658a commit 22ee1c0c0ccf6267f7f95c64630891914a6a13b6 @andrewssobral committed Feb 25, 2017
Showing with 91 additions and 76 deletions.
  1. +2 −4 .gitignore
  2. +50 −33 CMakeLists.txt
  3. +29 −34 README_CMAKE_USERS.txt
  4. +1 −2 run_camera.sh
  5. +3 −0 run_demo.bat
  6. +0 −1 run_demo.sh
  7. +3 −0 run_demo2.bat
  8. +2 −0 run_demo2.sh
  9. +1 −2 run_video.sh
View
@@ -1,6 +1,6 @@
etc/
+build_*/
binaries/
-package_bgs/pt/
java_gui/dist/
java_gui/build/
java_gui/bgslibrary.exe
@@ -9,6 +9,4 @@ qt_gui/
fet/etc/
*.exe
*.pdb
-vs2010mfc/src/bgslibrary_vs2010_mfc.aps
-*.suo
-vs2010mfc/src/bgslibrary_vs2010_mfc.v12.suo
+*.suo
View
@@ -1,20 +1,33 @@
cmake_minimum_required(VERSION 2.8)
-project(bgs)
+project(bgslibrary)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)
+set( bgs_out_dir "." )
+# First for the generic no-config case (e.g. with mingw)
+set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${bgs_out_dir} )
+set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${bgs_out_dir} )
+set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${bgs_out_dir} )
+# Second, for multi-config builds (e.g. msvc)
+foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
+ string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
+ set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${bgs_out_dir} )
+ set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${bgs_out_dir} )
+ set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${bgs_out_dir} )
+endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
+
IF(UNIX)
- # add some standard warnings
- ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas)
-
- # -ansi does not compile with sjn module
- #ADD_DEFINITIONS(-ansi)
-
- # if you like to have warinings about conversions, e.g. double->int or double->float etc., or float compare
- #ADD_DEFINITIONS(-Wconversion -Wfloat-equal)
+ # add some standard warnings
+ ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas)
+
+ # -ansi does not compile with sjn module
+ #ADD_DEFINITIONS(-ansi)
+
+ # if you like to have warinings about conversions, e.g. double->int or double->float etc., or float compare
+ #ADD_DEFINITIONS(-Wconversion -Wfloat-equal)
endif(UNIX)
find_package(OpenCV REQUIRED)
@@ -25,52 +38,56 @@ message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
if(${OpenCV_VERSION} VERSION_EQUAL 3 OR ${OpenCV_VERSION} VERSION_GREATER 3)
- message (FATAL_ERROR "OpenCV version is not compatible: ${OpenCV_VERSION}")
+ message(FATAL_ERROR "OpenCV version is not compatible: ${OpenCV_VERSION}")
endif()
if(${OpenCV_VERSION} VERSION_LESS 2.3.1)
- message (FATAL_ERROR "OpenCV version is not compatible: ${OpenCV_VERSION}")
+ message(FATAL_ERROR "OpenCV version is not compatible: ${OpenCV_VERSION}")
endif()
file(GLOB sources FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp)
file(GLOB main Main.cpp)
file(GLOB demo Demo.cpp)
file(GLOB demo2 Demo2.cpp)
-list(REMOVE_ITEM sources ${demo} ${demo2})
+# list(REMOVE_ITEM sources ${demo} ${demo2})
-file(GLOB_RECURSE analysis package_analysis/*.cpp)
-file(GLOB_RECURSE bgs package_bgs/*.cpp package_bgs/*.c)
+file(GLOB_RECURSE analysis_src package_analysis/*.cpp)
+file(GLOB_RECURSE bgs_src package_bgs/*.cpp package_bgs/*.c)
file(GLOB_RECURSE bgs_include package_bgs/*.h)
# GMG is not available in older OpenCV versions
if(${OpenCV_VERSION} VERSION_LESS 2.4.3)
- file(GLOB gmg package_bgs/GMG.cpp)
- list(REMOVE_ITEM bgs ${gmg})
+ file(GLOB gmg package_bgs/GMG.cpp)
+ list(REMOVE_ITEM bgs_src ${gmg})
endif()
include_directories(${CMAKE_SOURCE_DIR})
-add_library(bgs SHARED ${sources} ${bgs} ${analysis})
-target_link_libraries(bgs ${OpenCV_LIBS})
-set_property(TARGET bgs PROPERTY PUBLIC_HEADER ${bgs_include})
+add_library(libbgs STATIC ${sources} ${bgs_src} ${analysis_src})
+target_link_libraries(libbgs ${OpenCV_LIBS})
+set_property(TARGET libbgs PROPERTY PUBLIC_HEADER ${bgs_include})
+if(WIN32)
+ # set_property(TARGET libbgs PROPERTY SUFFIX ".lib")
+else()
+ set_property(TARGET libbgs PROPERTY OUTPUT_NAME "bgs")
+endif()
-add_executable(bgs_bin ${main})
-target_link_libraries(bgs_bin ${OpenCV_LIBS} bgs)
-set_target_properties(bgs_bin
- PROPERTIES OUTPUT_NAME bgs)
+add_executable(bgslibrary ${main})
+target_link_libraries(bgslibrary ${OpenCV_LIBS} libbgs)
+# set_target_properties(bgslibrary PROPERTIES OUTPUT_NAME bgs)
add_executable(bgs_demo ${demo})
-target_link_libraries(bgs_demo ${OpenCV_LIBS} bgs)
+target_link_libraries(bgs_demo ${OpenCV_LIBS} libbgs)
add_executable(bgs_demo2 ${demo2})
-target_link_libraries(bgs_demo2 ${OpenCV_LIBS} bgs)
-
-INSTALL(TARGETS bgs
- bgs_bin
- RUNTIME DESTINATION bin COMPONENT app
- LIBRARY DESTINATION lib COMPONENT runtime
- ARCHIVE DESTINATION lib COMPONENT runtime
- PUBLIC_HEADER DESTINATION include/package_bgs COMPONENT dev
- FRAMEWORK DESTINATION "/Library/Frameworks"
+target_link_libraries(bgs_demo2 ${OpenCV_LIBS} libbgs)
+
+INSTALL(TARGETS libbgs
+ bgslibrary
+ RUNTIME DESTINATION bin COMPONENT app
+ LIBRARY DESTINATION lib COMPONENT runtime
+ ARCHIVE DESTINATION lib COMPONENT runtime
+ PUBLIC_HEADER DESTINATION include/package_bgs COMPONENT dev
+ FRAMEWORK DESTINATION "/Library/Frameworks"
)
View
@@ -1,14 +1,14 @@
-------------------------------------------------
-------------- WINDOWS CMAKE USERS --------------
-How to build BGSLibrary with OpenCV 2.4.10 and Visual Studio 2010 from CMAKE.
+How to build BGSLibrary with OpenCV 2.4.10 and Visual Studio 2013 from CMAKE.
For Linux users, please see the instruction in README_LINUX_USERS.txt file.
Dependencies:
* GIT (tested with git version 2.7.2.windows.1).
* CMAKE for Windows (tested with cmake version 3.1.1).
-* Microsoft Visual Studio (tested with VS2015).
+* Microsoft Visual Studio (tested with VS2013).
Please follow the instructions below:
@@ -24,59 +24,54 @@ e.g.: C:\bgslibrary\build>_
e.g.:
\> setlocal
\> set OpenCV_DIR=C:\OpenCV2.4.10\build
-\> cmake -DOpenCV_DIR=%OpenCV_DIR% -G "Visual Studio 10" ..
+\> cmake -DOpenCV_DIR=%OpenCV_DIR% -G "Visual Studio 12" ..
or:
-\> cmake -DOpenCV_DIR=%OpenCV_DIR% -G "Visual Studio 10 Win64" ..
+\> cmake -DOpenCV_DIR=%OpenCV_DIR% -G "Visual Studio 12 Win64" ..
-Now, you will see something like:
+Now, you will see something like (for win64):
-------------------------------------------------
-C:\bgslibrary\build>cmake -DOpenCV_DIR=C:\OpenCV2.4.10\build -G "Visual Studio 10" ..
--- The C compiler identification is MSVC 16.0.40219.1
--- The CXX compiler identification is MSVC 16.0.40219.1
--- Check for working C compiler using: Visual Studio 10 2010
--- Check for working C compiler using: Visual Studio 10 2010 -- works
+-- The C compiler identification is MSVC 18.0.40629.0
+-- The CXX compiler identification is MSVC 18.0.40629.0
+-- Check for working C compiler using: Visual Studio 12 2013 Win64
+-- Check for working C compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
--- Check for working CXX compiler using: Visual Studio 10 2010
--- Check for working CXX compiler using: Visual Studio 10 2010 -- works
+-- Check for working CXX compiler using: Visual Studio 12 2013 Win64
+-- Check for working CXX compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
--- OpenCV ARCH: x86
--- OpenCV RUNTIME: vc10
+-- Detecting CXX compile features
+-- Detecting CXX compile features - done
+-- OpenCV ARCH: x64
+-- OpenCV RUNTIME: vc12
-- OpenCV STATIC: OFF
--- Found OpenCV 2.4.10 in C:/OpenCV2.4.10/build/x86/vc10/lib
--- You might need to add C:\OpenCV2.4.10\build\x86\vc10\bin to your PATH to be able to run your appl
-ications.
+-- Found OpenCV 2.4.10 in C:/OpenCV2.4.10/build/x64/vc12/lib
+-- You might need to add C:\OpenCV2.4.10\build\x64\vc12\bin to your PATH to be able to run your applications.
-- Configuring done
-- Generating done
--- Build files have been written to: E:/GitHubbkp2/bgslibrary_opencv2/build
-C:\bgslibrary\build>
+-- Build files have been written to: C:/bgslibrary/build
-------------------------------------------------
3) Include OpenCV binaries in the system path:
-\> set PATH=%PATH%;%OpenCV_DIR%\x86\vc10\bin
+\> set PATH=%PATH%;%OpenCV_DIR%\x86\vc12\bin
or:
-\> set PATH=%PATH%;%OpenCV_DIR%\x64\vc10\bin
+\> set PATH=%PATH%;%OpenCV_DIR%\x64\vc12\bin
4) Open 'bgs.sln' in Visual Studio and switch to 'RELEASE' mode
-4.1) Note if you are using a Visual Studio version superior than 10, you will need to CANCEL the project wizard update. However, you can go to step (2) and change the Visual Studio version, e.g.: -G "Visual Studio XXX", where XXX is your Visual Studio version.
+4.1) Note if you are using a Visual Studio version superior than 2013, you will need to CANCEL the project wizard update. However, you can go to step (2) and change the Visual Studio version, e.g.: -G "Visual Studio XX", where XX is your Visual Studio version.
-5) Click on 'bgs' project, and set:
-[Configuration Type] Static library (.lib)
-[Target Extension] .lib
+5) Click on 'ALL_BUILD' project and build!
-6) Click on 'ALL_BUILD' project and build!
+6) If everything goes well, you can run bgslibrary in the Windows console as follows:
-7) If everything goes well, you can run bgslibrary in the Windows console as follows:
+6.1) Running BGSLibrary with a webcamera:
+C:\bgslibrary> build\bgslibrary.exe --use_cam --camera=0
-7.1) Running BGSLibrary with a webcamera:
-C:\bgslibrary> build\Release\bgs.exe --use_cam --camera=0
+6.2) Running demo code:
+C:\bgslibrary> build\bgs_demo.exe dataset/video.avi
-7.2) Running demo code:
-C:\bgslibrary> build\Release\bgs_demo.exe dataset/video.avi
-
-7.3) Running demo2 code:
-C:\bgslibrary> build\Release\bgs_demo2.exe
+6.3) Running demo2 code:
+C:\bgslibrary> build\bgs_demo2.exe
Additional information:
* Note that bgslibrary requires a 'config' folder in the working directory.
View
@@ -1,3 +1,2 @@
#!/bin/bash
-./build/bgs --use_cam --camera=0
-
+./build/bgslibrary --use_cam --camera=0
View
@@ -0,0 +1,3 @@
+@echo off
+cls
+build\bgs_demo.exe dataset/video.avi
View
@@ -1,3 +1,2 @@
#!/bin/bash
./build/bgs_demo dataset/video.avi
-
View
@@ -0,0 +1,3 @@
+@echo off
+cls
+build\bgs_demo2.exe
View
@@ -0,0 +1,2 @@
+#!/bin/bash
+./build/bgs_demo2
View
@@ -1,3 +1,2 @@
#!/bin/bash
-./build/bgs -uf -fn=dataset/video.avi
-
+./build/bgslibrary -uf -fn=dataset/video.avi

0 comments on commit 22ee1c0

Please sign in to comment.