1 | # Matlab toolbox of functions from BDM |
---|
2 | |
---|
3 | cmake_minimum_required(VERSION 2.6) |
---|
4 | PROJECT(doprava) |
---|
5 | |
---|
6 | # Link it to BDM |
---|
7 | SET(BDM_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../library") |
---|
8 | SET(CMAKE_MODULE_PATH "${BDM_SOURCE_DIR}/system") |
---|
9 | |
---|
10 | # Load BDM environment |
---|
11 | INCLUDE(SetBdmEnv) |
---|
12 | |
---|
13 | if ( WIN32 ) |
---|
14 | # Define where the DLLs will be copied after building them. This path has |
---|
15 | # to be passed as a preprocessor definition when building AimsunDS so that |
---|
16 | # the resulting executable will know where to look for DLL files. |
---|
17 | set ( DLL_DIRECTORY "${CMAKE_SOURCE_DIR}/aimsun_bdm/dlls" ) |
---|
18 | set ( ELS_DIRECTORY "${CMAKE_SOURCE_DIR}/aimsun_bdm/els3" ) |
---|
19 | # Define macro for copying the DLLs to DLL_DIRECTORY |
---|
20 | # This is not very pretty ... we need to use different DLL names |
---|
21 | # for Debug and Release versions of the code and CMake does not offer |
---|
22 | # any property or variable that would reflect the proper target library |
---|
23 | # name. Hence, we have to use Visual Studio macros. Aaaarrrgggh. |
---|
24 | macro ( copydll DLL_TARGET DLL_DIR ) |
---|
25 | add_custom_command ( |
---|
26 | TARGET ${DLL_TARGET} |
---|
27 | POST_BUILD |
---|
28 | COMMENT "Saving a copy of the ${DLL_TARGET} DLL to ${DLL_DIR} ..." |
---|
29 | COMMAND echo md "${DLL_DIR}" |
---|
30 | COMMAND ${CMAKE_COMMAND} -E make_directory "${DLL_DIR}" |
---|
31 | COMMAND echo copy "$(TargetPath)" "${DLL_DIR}" |
---|
32 | COMMAND ${CMAKE_COMMAND} -E copy "$(TargetPath)" "${DLL_DIR}" |
---|
33 | VERBATIM |
---|
34 | ) |
---|
35 | endmacro ( copydll ) |
---|
36 | endif ( WIN32 ) |
---|
37 | |
---|
38 | include_directories (${BDM_SOURCE_DIR}/bdm) |
---|
39 | link_directories (${BDM_SOURCE_DIR}/bdm) |
---|
40 | |
---|
41 | add_subdirectory (aimsun_bdm) |
---|
42 | link_directories (./aimsun_bdm ./aimsun_bdm/eh_api ./aimsun_bdm/vgs_api) |
---|
43 | |
---|
44 | add_library(traffic_agents traffic_agent.cpp traffic_agent.h) |
---|
45 | |
---|
46 | IF(WIN32) |
---|
47 | include_directories ( aimsun_bdm/eh_api aimsun_bdm/els3/include aimsun_bdm/vgs_api ) |
---|
48 | # executable |
---|
49 | exec ( main_loop traffic_agents aimsun_bdm eh_api vgs_api ) |
---|
50 | # Delay load the following DLL libraries. Some of them will not be linked at all, |
---|
51 | # unfortunately we have no means to determine if we are building a Debug or Release |
---|
52 | # version - have we have to specify all possible DLL versions. |
---|
53 | set_property ( |
---|
54 | TARGET main_loop |
---|
55 | PROPERTY LINK_FLAGS "/DELAYLOAD:eh_api.dll /DELAYLOAD:eh_apid.dll /DELAYLOAD:vgs_api.dll /DELAYLOAD:vgs_apid.dll" |
---|
56 | ) |
---|
57 | target_link_libraries ( main_loop Delayimp.lib ) |
---|
58 | ELSE(WIN32) |
---|
59 | EXEC(main_loop aimsun_bdm traffic_agents ) |
---|
60 | ENDIF(WIN32) |
---|
61 | |
---|