Commit b954f8cf authored by Yann Voté's avatar Yann Voté Committed by Sebastien Petitdemange

[CMake] work by Yann Voté

This is a combination of 17 commits.
Make shared install targets work on Win32
Error message is 'install library TARGETS given no DESTINATION!'
See
http://stackoverflow.com/questions/14990343/cmake-error-targets-given-no-library-destination-for-shared-library-target
[simulator/cmake] Make shared install targets work on Win32
Error message is 'install library TARGETS given no DESTINATION!'
See
http://stackoverflow.com/questions/14990343/cmake-error-targets-given-no-library-destination-for-shared-library-target
[cmake] Fix duplicate path for created folder
On Windows, Cmake ends up trying to create
`C:\...\simulatorC:\...\simulator\sip` folder and aborts with error
`file problem creating directory`.
Or `Could not create output directory
C:\...\_build\C:\...\_build\sip\core`
So remove duplicate path.
[cmake] Add Processlib include folder for windows
This folder contains many Windows specific header files. And most
notably a Windows version of `pthread.h`.
Hence error message `pthread.h: no such file or directory` disapears.
[cmake] Do not use HwFileEventMgr.cpp
This file causes an error due to missing dirent.h on Windows. Plus it is
not included in .vcproj files before CMake was introduced.
[cmake] Do not use RegExUtils.cpp
This file causes an error due to missing regex.h on Windows. Plus it is
not included in .vcproj files before CMake was introduced.
[cmake] Add compile definition to fix dllimport error
Error message is `definition of dllimport: static data member not
allowed`
The ``LIMACORE_EXPORTS`` variable is used in LimaCompatibility.h header
file.
[cmake] Link to rt only in Linux
rt.lib does not exists in Windows.
[cmake] Do not use env var to checksipexc.py execution
Using environment variable to decide whether or not to execute the script
is not portable in Windows.
Since this script should be run only for camera, use string comparison
instead (is `camera` in the name).
[cmake] Add variables so that msbuild find NumPy
On Windows, the GNU Scientific Library gets installed in a specific
folder. So for msbuild.exe to find it, we add more variables that can be
used when invoking cmake. For example:
cmake -D NUMPY_INCLUDE_DIR="C:\Anaconda2\Lib\site-packages\numpy\core\include" ...
This is needed because of error message `numpyconfig.h: no such file or
directory`
[cmake] Export library as .dll (not as .lib)
Hence get rid of `output filename matches input filename` error message.
[simulator/cmake] Add compile definition to fix dllimport error
Error message is `unresolved external symbol __declspec(dllimport)`
The ``LIBSIMULATOR_EXPORTS`` variable is used in
SimulatorCompatibility.h header file.
[cmake] Do no use sip splits for simulator camera
For the simulator camera, only 5 files are generated by SIP
(`siplimasimulatorpart{0,1,2,3,4}.cpp`). Hence the process crash
trying to find file number 5 (`No such file or directory
siplimasimulatorpart5.cpp`)
Put everything in one file.
[cmake] Do not use GCC specific flags on Windows
`-Wl` and `--no-undefined` are specific to GCC. On windows, we end up
with a warning `unrecognized option`.
We suppress this warning.
[cmake] Make windows install script find CMake paths
Adapt Windows install script to the CMake tree. Build files are not in
the same place than previously.
[cmake] Update install script to CMake
There is now only one solution file to build.
[cmake] Add lib prefix to target on Windows
parent bf3d6e85
......@@ -16,9 +16,18 @@ INCLUDE(SIPMacros)
SET(PYTHON_SITE_PACKAGES_DIR ${_PYTHON_SITE_PACKAGES_DIR} CACHE PATH "where should python modules be installed?")
IF (WIN32)
SET(NUMPY_INCLUDE_DIR "/usr/include" CACHE PATH "Path to NumPy include folder")
SET(NUMPY_LIB_DIR "/usr/include" CACHE PATH "Path to NumPy lib folder")
include_directories(${NUMPY_INCLUDE_DIR})
link_directories(${NUMPY_LIB_DIR})
ENDIF()
find_package(Threads REQUIRED)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
IF(UNIX)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
ENDIF(UNIX)
set(COMPILE_CORE ON CACHE BOOL "compile core?")
set(COMPILE_SIMULATOR ON CACHE BOOL "compile simulator?")
......@@ -40,6 +49,9 @@ if(COMPILE_SIP)
endif(COMPILE_SIP)
add_subdirectory(third-party/Processlib)
if(WIN32)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third-party/Processlib/core/include/WindowSpecific")
endif(WIN32)
set(common_srcs common/src/Constants.cpp common/src/SizeUtils.cpp common/src/Timestamp.cpp common/src/ThreadUtils.cpp
common/src/Exceptions.cpp common/src/MemUtils.cpp common/src/RegExUtils.cpp common/src/AcqState.cpp
......@@ -49,6 +61,10 @@ set(common_srcs common/src/Constants.cpp common/src/SizeUtils.cpp common/src/Tim
# set(config_objs common/src/ConfigUtils.cpp)
#endif (0 and COMPILE_CONFIG)
if(WIN32)
list(REMOVE_ITEM common_srcs common/src/RegExUtils.cpp)
endif()
set(hw_srcs hardware/src/HwInterface.cpp hardware/src/HwCap.cpp hardware/src/HwSyncCtrlObj.cpp hardware/src/HwFrameInfo.cpp
hardware/src/HwFrameCallback.cpp hardware/src/HwBufferCtrlObj.cpp hardware/src/HwBufferMgr.cpp
hardware/src/HwShutterCtrlObj.cpp hardware/src/HwMaxImageSizeCallback.cpp hardware/src/HwDetInfoCtrlObj.cpp
......@@ -56,6 +72,10 @@ set(hw_srcs hardware/src/HwInterface.cpp hardware/src/HwCap.cpp hardware/src/HwS
hardware/src/HwBufferSave.cpp hardware/src/HwVideoCtrlObj.cpp hardware/src/HwEventCtrlObj.cpp hardware/src/HwSavingCtrlObj.cpp
hardware/src/HwFileEventMgr.cpp hardware/src/HwReconstructionCtrlObj.cpp)
if(WIN32)
list(REMOVE_ITEM hw_srcs hardware/src/HwFileEventMgr.cpp)
endif()
set(control_srcs control/src/CtSaving.cpp control/src/CtControl.cpp control/src/CtAcquisition.cpp control/src/CtBuffer.cpp
control/src/CtImage.cpp control/src/CtSaving_Edf.cpp control/src/CtShutter.cpp control/src/CtAccumulation.cpp control/src/CtVideo.cpp
control/src/CtEvent.cpp)
......@@ -97,12 +117,26 @@ endif()
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(limacore "${CMAKE_THREAD_LIBS_INIT}")
endif()
TARGET_LINK_LIBRARIES(limacore "rt")
if(UNIX)
TARGET_LINK_LIBRARIES(limacore "rt")
endif()
TARGET_LINK_LIBRARIES(limacore processlib)
if(WIN32)
TARGET_COMPILE_DEFINITIONS(limacore PRIVATE LIMACORE_EXPORTS)
endif()
SET_TARGET_PROPERTIES(limacore PROPERTIES VERSION ${core_ver} SOVERSION "1")
INSTALL(TARGETS limacore
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include)
if(WIN32)
SET_TARGET_PROPERTIES(limacore PROPERTIES PREFIX "lib")
endif()
if(WIN32)
INSTALL(TARGETS limacore
DESTINATION lib
PUBLIC_HEADER DESTINATION include)
else()
INSTALL(TARGETS limacore
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include)
endif()
if(COMPILE_SIMULATOR)
add_subdirectory(camera/simulator)
......
......@@ -10,9 +10,20 @@ TARGET_INCLUDE_DIRECTORIES(limasimulator PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc
TARGET_INCLUDE_DIRECTORIES(limasimulator PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../common/include")
TARGET_INCLUDE_DIRECTORIES(limasimulator PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../hardware/include")
TARGET_LINK_LIBRARIES(limasimulator limacore)
if(WIN32)
TARGET_COMPILE_DEFINITIONS(limasimulator PRIVATE LIBSIMULATOR_EXPORTS)
endif()
SET_TARGET_PROPERTIES(limasimulator PROPERTIES VERSION ${simu_ver} SOVERSION "1")
INSTALL(TARGETS limasimulator
LIBRARY DESTINATION lib)
if(WIN32)
SET_TARGET_PROPERTIES(limasimulator PROPERTIES PREFIX "lib")
endif()
if(WIN32)
INSTALL(TARGETS limasimulator
DESTINATION lib)
else()
INSTALL(TARGETS limasimulator
LIBRARY DESTINATION lib)
endif()
IF (COMPILE_SIP)
SET(NAME "simulator")
......@@ -28,6 +39,7 @@ IF (COMPILE_SIP)
ENDFOREACH()
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sip/limamodules.sip.in sip/limasimulator.sip)
SET(SIP_CONCAT_PARTS 1)
SET(SIP_INCLUDES ${SIP_INCLUDES}
"${CMAKE_SOURCE_DIR}/third-party/Processlib/sip"
"${CMAKE_BINARY_DIR}/sip/core"
......
......@@ -40,7 +40,6 @@ SET(SIP_TAGS)
SET(SIP_CONCAT_PARTS 8)
SET(SIP_DISABLE_FEATURES)
SET(SIP_EXTRA_OPTIONS)
SET(SIP_CHECK_EXC OFF)
MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
......@@ -60,7 +59,7 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
STRING(REPLACE "." "_" _logical_name ${MODULE_NAME})
SET(_logical_name "python_module_${_logical_name}")
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_module_path}) # Output goes in this dir.
FILE(MAKE_DIRECTORY ${_module_path}) # Output goes in this dir.
SET(_sip_includes)
FOREACH (_inc ${SIP_INCLUDES})
......@@ -82,7 +81,7 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
SET(_sip_output_files)
FOREACH(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
IF( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
SET(_sip_output_files ${_sip_output_files} ${CMAKE_CURRENT_BINARY_DIR}/${_module_path}/sip${_child_module_name}part${CONCAT_NUM}.cpp )
SET(_sip_output_files ${_sip_output_files} ${_module_path}/sip${_child_module_name}part${CONCAT_NUM}.cpp )
ENDIF( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
ENDFOREACH(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
......@@ -100,8 +99,8 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
OUTPUT ${_sip_output_files}
COMMAND ${CMAKE_COMMAND} -E echo ${message}
COMMAND ${TOUCH_COMMAND} ${_sip_output_files}
COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_BINARY_DIR}/${_module_path} ${_sip_includes} ${_abs_module_sip}
COMMAND env SIP_CHECK_EXC=${SIP_CHECK_EXC} ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/sip/checksipexc.py ${_sip_output_files}
COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${_module_path} ${_sip_includes} ${_abs_module_sip}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/sip/checksipexc.py ${_sip_output_files}
DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND}
)
# not sure if type MODULE could be uses anywhere, limit to cygwin for now
......@@ -116,6 +115,7 @@ MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
IF (WIN32)
SET_TARGET_PROPERTIES(${_logical_name} PROPERTIES SUFFIX ".pyd")
SET_TARGET_PROPERTIES(${_logical_name} PROPERTIES IMPORT_SUFFIX ".dll")
ENDIF (WIN32)
INSTALL(TARGETS ${_logical_name} DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/${_parent_module_path}")
......
......@@ -2,65 +2,35 @@
setlocal enabledelayedexpansion
rem repertoire courant du batch
if exist "_build" (
rmdir /S /Q _build
)
mkdir _build
cd _build
set CurrentPath=%cd%
rem execution de cmake pour créer les fichiers projets et solution
cmake -G "Visual Studio 9 2008" -D PYLON_ROOT="C:\Program Files\Basler\pylon 3.2\pylon" -D GSL_INCLUDE_DIR="C:\Program Files (x86)\GnuWin32\include" -D GSL_LIB_DIR="C:\Program Files (x86)\GnuWin32\lib" -D NUMPY_INCLUDE_DIR="C:\Anaconda2\Lib\site-packages\numpy\core\include" -D NUMPY_LIB_DIR="C:\Anaconda2\Lib\site-packages\numpy\core\lib" -D COMPILE_SIP=1 -D COMPILE_SPS_IMAGE=0 ..
rem configuration des variables d'environnement visual c++ 2008 express edition
cd /D %VS90COMNTOOLS%..\..\VC
call vcvarsall.bat
rem compilation de la librairie libprocesslib
cd /D %CurrentPath%\third-party\Processlib\build\msvc\9.0\libprocesslib
msbuild.exe libprocesslib.sln /t:build /fl /flp:logfile=MyProjectOutput.log /p:Configuration=Release;Plateform=Win32 /v:d
rem compilation de la librairie limacore
cd /D %CurrentPath%\build\msvc\9.0\LimaCore
msbuild.exe LimaCore.sln /t:build /fl /flp:logfile=MyProjectOutput.log /p:Configuration=Release;Plateform=Win32 /v:d
rem compilation des plugins des cameras actives dans le fichier config.inc
for /f "delims=:" %%i in ('type %CurrentPath%\config.inc') do (
set ligne=%%i
set ligne_temp=%%i
if "!ligne:~0,7!" == "COMPILE" (
rem call:strlen longueur !ligne!
rem echo longueur : !longueur!
if "!ligne:~-1!" == "1" (
if not "!ligne:~8,-2!" == "CORE" (
rem compilation du plugin active
cd /D !CurrentPath!\camera\!ligne:~8,-2!\build\msvc\9.0\lib!ligne:~8,-2!
msbuild.exe Lib!ligne:~8,-2!.sln /t:build /fl /flp:logfile=MyProjectOutput.log /p:Configuration=Release;Plateform=Win32 /v:d
)
)
)
)
rem execution du script python configure.py
cd /D %CurrentPath%\third-party\Processlib\sip
call python configure.py
rem execution du script python windowsSipCompilation --config
rem compilation
cd /D %CurrentPath%
call python windowsSipCompilation.py --config
cd /D %CurrentPath%\third-party\Processlib\sip
call nmake
rem execution du script python windowsSipCompilation
cd /D %CurrentPath%
call python windowsSipCompilation.py
msbuild.exe lima.sln /t:build /fl /flp:logfile=limaOutput.log /p:Configuration=Release;Plateform=Win32 /v:d
rem execution du script python windowsInstall
cd /D %CurrentPath%
cd ..
if exist "python_path.tmp" (
del python_path.tmp
)
call python_path.py
call python python_path.py
set /p python_path= < python_path.tmp
call python windowsInstall.py --install_dir=%python_path%
if exist "python_path.tmp" (
del python_path.tmp
)
cd /D %CurrentPath%
......@@ -108,18 +108,9 @@ def checksipexc(ifname, inplace=False):
if __name__ == '__main__':
sip_check_exc = os.environ.get('SIP_CHECK_EXC')
if sip_check_exc is None:
# run from command line
logging.basicConfig(level=logging.DEBUG, format="%(message)s")
if checksipexc(sys.argv[1], inplace=False):
sys.exit(1)
elif sip_check_exc == 'OFF':
# run from cmake with SIP_CHECK_EXC disabled
sys.exit(0)
else:
# run from cmake with SIP_CHECK_EXC enabled
srcs = []
for src in sys.argv[1:]:
for src in sys.argv[1:]:
if 'camera' in src:
checksipexc(src, inplace=True)
sys.exit(0)
else:
continue
sys.exit(0)
......@@ -3,53 +3,39 @@ import platform
from windowsSipCompilation import getModuleConfig
from optparse import OptionParser
BUILDDIR = '_build'
global module2Installfiles
module2Installfiles = {}
if platform.machine() == 'AMD64':
module2Installfiles = {
'core' : [('__init__.py','Lima'),
('common/python/Core.py','Lima'),
('common/python/Debug.py','Lima'),
('build/msvc/9.0/LimaCore/x64/Release/LibLimaCore.dll','Lima'),
('third-party/libconfig/lib/x64/Release/libconfig++.dll','Lima'),
('sip/core/limacore.pyd','Lima'),
('third-party/Processlib/sip/processlib.pyd','Lima'),
('third-party/Processlib/build/msvc/9.0/libprocesslib/x64/Release/libprocesslib.dll','Lima')],
'dexela' : [('camera/dexela/python/Dexela.py','Lima'),
('camera/dexela/src/DexelaConfig.cfg','Lima'),
('camera/dexela/build/msvc/9.0/LibDexela/x64/Release/liblimadexela.dll','Lima'),
('sip/dexela/limadexela.pyd','Lima')],
}
else:
module2Installfiles = {
'core' : [('__init__.py','Lima'),
('common/python/Core.py','Lima'),
('common/python/Debug.py','Lima'),
('build/msvc/9.0/LimaCore/Release/LibLimaCore.dll','Lima'),
('third-party\libconfig\lib\libconfig++.Release\libconfig++.dll','Lima'),
('sip/core/limacore.pyd','Lima'),
('third-party/Processlib/sip/processlib.pyd','Lima'),
('third-party/Processlib/build/msvc/9.0/libprocesslib/Release/libprocesslib.dll','Lima')],
'pco' : [('camera/pco/python/Pco.py','Lima'),
('camera/pco/build/msvc/9.0/liblimapco/Release/liblimapco.dll','Lima'),
('camera/pco/sdkPco/bin/SC2_Cam.dll','Lima'),
('camera/pco/sdkPco/bin/sc2_cl_me4.dll','Lima'),
('applications/tango/python/camera/Pco.py','camera'),
('sip/pco/limapco.pyd','Lima')],
'perkinelmer' : [('camera/perkinelmer/python/PerkinElmer.py','Lima'),
('camera/perkinelmer/build/msvc/9.0/LibPerkinElmer/Release/liblimaperkinelmer.dll','Lima'),
('sip/perkinelmer/limaperkinelmer.pyd','Lima')],
'photonicscience' : [('camera/photonicscience/python/PhotonicScience.py','Lima'),
('camera/photonicscience/build/msvc/9.0/LibPhotonicScience/Release/liblimaphotonicscience.dll','Lima'),
('camera/photonicscience/sdk/ImageStar4022_v1.7',''),
('sip/photonicscience/limaphotonicscience.pyd','Lima')],
'simulator' : [('camera/simulator/python/Simulator.py','Lima'),
('camera/simulator/build/msvc/9.0/LibSimulator/Release/liblimasimulator.dll','Lima'),
('sip/simulator/limasimulator.pyd','Lima')],
'basler' : [('camera/basler/python/Basler.py','Lima'),
('camera/basler/build/msvc/9.0/LibBasler/Release/liblimabasler.dll','Lima'),
('sip/basler/limabasler.pyd','Lima')],
}
module2Installfiles = {
'core' : [('__init__.py','Lima'),
('common/python/Core.py','Lima'),
('common/python/Debug.py','Lima'),
(BUILDDIR + '/Release/LibLimaCore.dll','Lima'),
('third-party\libconfig\lib\libconfig++.Release\libconfig++.dll','Lima'),
(BUILDDIR + '/Release/limacore.pyd','Lima'),
(BUILDDIR + '/third-party/Processlib/Release/processlib.pyd','Lima'),
(BUILDDIR + '/third-party/Processlib/Release/libprocesslib.dll','Lima')],
'pco' : [('camera/pco/python/Pco.py','Lima'),
('camera/pco/build/msvc/9.0/liblimapco/Release/liblimapco.dll','Lima'),
('camera/pco/sdkPco/bin/SC2_Cam.dll','Lima'),
('camera/pco/sdkPco/bin/sc2_cl_me4.dll','Lima'),
('applications/tango/python/camera/Pco.py','camera'),
('sip/pco/limapco.pyd','Lima')],
'perkinelmer' : [('camera/perkinelmer/python/PerkinElmer.py','Lima'),
('camera/perkinelmer/build/msvc/9.0/LibPerkinElmer/Release/liblimaperkinelmer.dll','Lima'),
('sip/perkinelmer/limaperkinelmer.pyd','Lima')],
'photonicscience' : [('camera/photonicscience/python/PhotonicScience.py','Lima'),
('camera/photonicscience/build/msvc/9.0/LibPhotonicScience/Release/liblimaphotonicscience.dll','Lima'),
('camera/photonicscience/sdk/ImageStar4022_v1.7',''),
('sip/photonicscience/limaphotonicscience.pyd','Lima')],
'simulator' : [('camera/simulator/python/Simulator.py','Lima'),
(BUILDDIR + '/camera/simulator/Release/liblimasimulator.dll','Lima'),
(BUILDDIR + '/camera/simulator/Release/limasimulator.pyd','Lima')],
'basler' : [('camera/basler/python/Basler.py','Lima'),
(BUILDDIR + '/camera/basler/Release/liblimabasler.dll','Lima'),
(BUILDDIR + '/camera/basler/Release/limabasler.pyd','Lima')],
}
#Add Src
module2Installfiles.update({
'tango-core' : [('applications/tango/python/LimaCCDs.py',''),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment