Skip to content
Snippets Groups Projects
Commit 22ee1c0c authored by Andrews Sobral's avatar Andrews Sobral
Browse files

Some fixes on CMakeLists

parent ad8658a0
No related branches found
No related tags found
No related merge requests found
etc/ etc/
build_*/
binaries/ binaries/
package_bgs/pt/
java_gui/dist/ java_gui/dist/
java_gui/build/ java_gui/build/
java_gui/bgslibrary.exe java_gui/bgslibrary.exe
...@@ -9,6 +9,4 @@ qt_gui/ ...@@ -9,6 +9,4 @@ qt_gui/
fet/etc/ fet/etc/
*.exe *.exe
*.pdb *.pdb
vs2010mfc/src/bgslibrary_vs2010_mfc.aps *.suo
*.suo \ No newline at end of file
vs2010mfc/src/bgslibrary_vs2010_mfc.v12.suo
\ No newline at end of file
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
project(bgs) project(bgslibrary)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules) #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) IF(UNIX)
# add some standard warnings # 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) 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 # -ansi does not compile with sjn module
#ADD_DEFINITIONS(-ansi) #ADD_DEFINITIONS(-ansi)
# if you like to have warinings about conversions, e.g. double->int or double->float etc., or float compare # 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_DEFINITIONS(-Wconversion -Wfloat-equal)
endif(UNIX) endif(UNIX)
find_package(OpenCV REQUIRED) find_package(OpenCV REQUIRED)
...@@ -25,11 +38,11 @@ message(STATUS " libraries: ${OpenCV_LIBS}") ...@@ -25,11 +38,11 @@ message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}") message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
if(${OpenCV_VERSION} VERSION_EQUAL 3 OR ${OpenCV_VERSION} VERSION_GREATER 3) 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() endif()
if(${OpenCV_VERSION} VERSION_LESS 2.3.1) 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() endif()
file(GLOB sources FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp) file(GLOB sources FrameProcessor.cpp PreProcessor.cpp VideoAnalysis.cpp VideoCapture.cpp)
...@@ -37,40 +50,44 @@ file(GLOB main Main.cpp) ...@@ -37,40 +50,44 @@ file(GLOB main Main.cpp)
file(GLOB demo Demo.cpp) file(GLOB demo Demo.cpp)
file(GLOB demo2 Demo2.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 analysis_src package_analysis/*.cpp)
file(GLOB_RECURSE bgs package_bgs/*.cpp package_bgs/*.c) file(GLOB_RECURSE bgs_src package_bgs/*.cpp package_bgs/*.c)
file(GLOB_RECURSE bgs_include package_bgs/*.h) file(GLOB_RECURSE bgs_include package_bgs/*.h)
# GMG is not available in older OpenCV versions # GMG is not available in older OpenCV versions
if(${OpenCV_VERSION} VERSION_LESS 2.4.3) if(${OpenCV_VERSION} VERSION_LESS 2.4.3)
file(GLOB gmg package_bgs/GMG.cpp) file(GLOB gmg package_bgs/GMG.cpp)
list(REMOVE_ITEM bgs ${gmg}) list(REMOVE_ITEM bgs_src ${gmg})
endif() endif()
include_directories(${CMAKE_SOURCE_DIR}) include_directories(${CMAKE_SOURCE_DIR})
add_library(bgs SHARED ${sources} ${bgs} ${analysis}) add_library(libbgs STATIC ${sources} ${bgs_src} ${analysis_src})
target_link_libraries(bgs ${OpenCV_LIBS}) target_link_libraries(libbgs ${OpenCV_LIBS})
set_property(TARGET bgs PROPERTY PUBLIC_HEADER ${bgs_include}) 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}) add_executable(bgslibrary ${main})
target_link_libraries(bgs_bin ${OpenCV_LIBS} bgs) target_link_libraries(bgslibrary ${OpenCV_LIBS} libbgs)
set_target_properties(bgs_bin # set_target_properties(bgslibrary PROPERTIES OUTPUT_NAME bgs)
PROPERTIES OUTPUT_NAME bgs)
add_executable(bgs_demo ${demo}) 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}) add_executable(bgs_demo2 ${demo2})
target_link_libraries(bgs_demo2 ${OpenCV_LIBS} bgs) target_link_libraries(bgs_demo2 ${OpenCV_LIBS} libbgs)
INSTALL(TARGETS bgs INSTALL(TARGETS libbgs
bgs_bin bgslibrary
RUNTIME DESTINATION bin COMPONENT app RUNTIME DESTINATION bin COMPONENT app
LIBRARY DESTINATION lib COMPONENT runtime LIBRARY DESTINATION lib COMPONENT runtime
ARCHIVE DESTINATION lib COMPONENT runtime ARCHIVE DESTINATION lib COMPONENT runtime
PUBLIC_HEADER DESTINATION include/package_bgs COMPONENT dev PUBLIC_HEADER DESTINATION include/package_bgs COMPONENT dev
FRAMEWORK DESTINATION "/Library/Frameworks" FRAMEWORK DESTINATION "/Library/Frameworks"
) )
------------------------------------------------- -------------------------------------------------
-------------- WINDOWS CMAKE USERS -------------- -------------- 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. For Linux users, please see the instruction in README_LINUX_USERS.txt file.
Dependencies: Dependencies:
* GIT (tested with git version 2.7.2.windows.1). * GIT (tested with git version 2.7.2.windows.1).
* CMAKE for Windows (tested with cmake version 3.1.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: Please follow the instructions below:
...@@ -24,59 +24,54 @@ e.g.: C:\bgslibrary\build>_ ...@@ -24,59 +24,54 @@ e.g.: C:\bgslibrary\build>_
e.g.: e.g.:
\> setlocal \> setlocal
\> set OpenCV_DIR=C:\OpenCV2.4.10\build \> 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: 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 18.0.40629.0
-- The C compiler identification is MSVC 16.0.40219.1 -- The CXX compiler identification is MSVC 18.0.40629.0
-- The CXX compiler identification is MSVC 16.0.40219.1 -- Check for working C compiler using: Visual Studio 12 2013 Win64
-- Check for working C compiler using: Visual Studio 10 2010 -- Check for working C compiler using: Visual Studio 12 2013 Win64 -- works
-- Check for working C compiler using: Visual Studio 10 2010 -- works
-- Detecting C compiler ABI info -- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done -- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 10 2010 -- Check for working CXX compiler using: Visual Studio 12 2013 Win64
-- Check for working CXX compiler using: Visual Studio 10 2010 -- works -- Check for working CXX compiler using: Visual Studio 12 2013 Win64 -- works
-- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done -- Detecting CXX compiler ABI info - done
-- OpenCV ARCH: x86 -- Detecting CXX compile features
-- OpenCV RUNTIME: vc10 -- Detecting CXX compile features - done
-- OpenCV ARCH: x64
-- OpenCV RUNTIME: vc12
-- OpenCV STATIC: OFF -- OpenCV STATIC: OFF
-- Found OpenCV 2.4.10 in C:/OpenCV2.4.10/build/x86/vc10/lib -- Found OpenCV 2.4.10 in C:/OpenCV2.4.10/build/x64/vc12/lib
-- You might need to add C:\OpenCV2.4.10\build\x86\vc10\bin to your PATH to be able to run your appl -- You might need to add C:\OpenCV2.4.10\build\x64\vc12\bin to your PATH to be able to run your applications.
ications.
-- Configuring done -- Configuring done
-- Generating done -- Generating done
-- Build files have been written to: E:/GitHubbkp2/bgslibrary_opencv2/build -- Build files have been written to: C:/bgslibrary/build
C:\bgslibrary\build>
------------------------------------------------- -------------------------------------------------
3) Include OpenCV binaries in the system path: 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: 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) 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: 5) Click on 'ALL_BUILD' project and build!
[Configuration Type] Static library (.lib)
[Target Extension] .lib
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: 6.2) Running demo code:
C:\bgslibrary> build\Release\bgs.exe --use_cam --camera=0 C:\bgslibrary> build\bgs_demo.exe dataset/video.avi
7.2) Running demo code: 6.3) Running demo2 code:
C:\bgslibrary> build\Release\bgs_demo.exe dataset/video.avi C:\bgslibrary> build\bgs_demo2.exe
7.3) Running demo2 code:
C:\bgslibrary> build\Release\bgs_demo2.exe
Additional information: Additional information:
* Note that bgslibrary requires a 'config' folder in the working directory. * Note that bgslibrary requires a 'config' folder in the working directory.
......
#!/bin/bash #!/bin/bash
./build/bgs --use_cam --camera=0 ./build/bgslibrary --use_cam --camera=0
@echo off
cls
build\bgs_demo.exe dataset/video.avi
\ No newline at end of file
#!/bin/bash #!/bin/bash
./build/bgs_demo dataset/video.avi ./build/bgs_demo dataset/video.avi
@echo off
cls
build\bgs_demo2.exe
\ No newline at end of file
#!/bin/bash
./build/bgs_demo2
#!/bin/bash #!/bin/bash
./build/bgs -uf -fn=dataset/video.avi ./build/bgslibrary -uf -fn=dataset/video.avi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment