Skip to content
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
44 changes: 44 additions & 0 deletions motoman_driver/MotoPlus/CMakeLists_with_vs_support.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#With Visual Studio support: existing .vcxproj (created by Visual Studio) and linked mps files (created by hand?) in git repository
#Note: remove "_with_vs_support" in filename to normally use this file with CMake

cmake_minimum_required(VERSION 3.0)

project(MpRosAllControllers NONE)

set(PROJECT_VERSION v192)

FILE(GLOB_RECURSE SOURCES "*.c")
FILE(GLOB_RECURSE HEADERS "*.h")
FILE(GLOB_RECURSE LIBS "*.*ib")
FILE(GLOB_RECURSE MPS "*.mps")

set(MPBUILDER_DIR "C:/Program Files (x86)/Yaskawa/MotoPlus for Visual Studio")
set(MPBUILDER_PATH ${MPBUILDER_DIR}/mpbuilder.exe)

macro(PROJECT_CONFIG name controller suffix)
set(path ${CMAKE_SOURCE_DIR}/output/${controller}/${name}${suffix})
string(REPLACE / \\ path ${path})
add_custom_target(${name}${suffix} ALL
SOURCES
${SOURCES}
${HEADERS}
${controller}CompilerArguments.mps
${controller}LinkerArguments.mps
COMMAND ${MPBUILDER_PATH}
-c ${controller}
-p ${CMAKE_SOURCE_DIR}
-n ${name}${suffix}
-l N
-d T
-o build
COMMAND rename
${path}\\${name}${suffix}.out
${name}${suffix}${PROJECT_VERSION}.out)
endmacro(PROJECT_CONFIG)

#Adding support for the application on several controllers
project_config(MotoRos DX100 DX1_)
project_config(MotoRos DX200 DX2_)
project_config(MotoRos FS100 FS_)
project_config(MotoRos YRC1000 YRC1u_)
project_config(MotoRos YRC1000u YRC1_)
Comment on lines +43 to +44
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The controller names and suffixes are mixed up here

159 changes: 159 additions & 0 deletions motoman_driver/MotoPlus/CMakeLists_without_vs_support.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#Without Visual Studio support: .vcxproj and linked mps files are automatically generated on the fly by CMake macro
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the purpose of this file.

The other file uses the information already present in the mps file and avoids any duplication. It allows generating build configuration for VS, Makefiles or any other CMake target, that will use the mpbuilder.exe from MotoPlus for Visual Studio, which is useful.

This file just produces the same results, only with the difference of spelling everything out explicitly?

#Note: remove "_without_vs_support" in filename to normally use this file with CMake

cmake_minimum_required(VERSION 3.0)

project(MotoRos NONE)

set(SRCS
./Controller.c
./CtrlGroup.c
./IoServer.c
./MotionServer.c
./mpMain.c
./SimpleMessage.c
./StateServer.c
)

set(HEADERS
./Controller.h
./CtrlGroup.h
./IoServer.h
./MotionServer.h
./MotoROS.h
./ParameterExtraction.h
./ParameterTypes.h
./SimpleMessage.h
./StateServer.h
)

#.*lib files (don't put extension, automatically suffixed according controller version) are in fact .a files obtained from .c files
set(LIBS
./ParameterExtraction
)

#set(CMAKE_VERBOSE_MAKEFILE ON)

set(MPBUILDER_DIR "C:/Program Files (x86)/Yaskawa/MotoPlus for Visual Studio")
set(MPBUILDER_PATH ${MPBUILDER_DIR}/mpbuilder.exe)

set(PROJECT_VERSION _v192)

set(COMPILER_OPTIONS
-march=atom
-nostdlib
-fno-builtin
-fno-defer-pop
-fno-implicit-fp
-fno-zero-initialized-in-bss
-Wall
-Werror-implicit-function-declaration
-g
-MD
-MP
-DCPU=_VX_ATOM
-DTOOL_FAMILY=gnu
-DTOOL=gnu
-D_WRS_KERNEL
-DDEBUG=1
)

set(LINKER_OPTIONS
-nostdlib
-r
-WI,-X
)

macro(PROJECT_CONFIG projectName controller)
set(${controller}_COMPILER_OPTIONS
${COMPILER_OPTIONS}
-D${controller})
set(${controller}_LINKER_OPTIONS
${LINKER_OPTIONS})
if(${controller} MATCHES DX100)
set(LIBEXT .mpLib)
elseif(${controller} MATCHES DX200)
set(LIBEXT .dnLib)
elseif(${controller} MATCHES FS100)
set(LIBEXT .fsLib)
elseif(${controller} MATCHES YRC1000)
set(LIBEXT .yrcmLib)
elseif(${controller} MATCHES YRC1000u)
set(LIBEXT .yrcmuLib)
else()
set(LIBEXT .a)
endif()
set(name ${projectName})
set(MOTOPLUSPROJECT_DIR ${CMAKE_SOURCE_DIR}/${name})
set(SRCS_
${SRCS}
)
set(HEADERS_
${HEADERS}
)

#Writing compiler arguments file
set(COMPILER_OPTIONS_
${${controller}_COMPILER_OPTIONS}
-DMOTOPLUS
-I\"~ProjectDir~\"
-I\"~IncludeDir~\"
-I\"${CMAKE_SOURCE_DIR}/..\"
-O2
-c \"~FilePath~\"
-o \"~OutputPath~\")
string(REPLACE ";" " " COMPILER_OPTIONS_ "${COMPILER_OPTIONS_}")
file(WRITE ${MOTOPLUSPROJECT_DIR}/${controller}CompilerArguments.mps ${COMPILER_OPTIONS_})

#Writing linker arguments file
foreach(lib ${LIBS})
set(fullPathLib "")
get_filename_component(fullPathLib ${lib}${LIBEXT} ABSOLUTE)
set(fullPathLibs ${fullPathLibs} ${fullPathLib})
endforeach(lib)
set(LINKER_OPTIONS_
${${controller}_LINKER_OPTIONS}
-WI~FileList~ ${fullPathLibs}
-o \"~OutputPath~\")
string(REPLACE ";" " " LINKER_OPTIONS_ "${LINKER_OPTIONS_}")
file(WRITE ${MOTOPLUSPROJECT_DIR}/${controller}LinkerArguments.mps ${LINKER_OPTIONS_})

#Writing VC project file
set(ITEMS ${SRCS_} ${HEADERS_})
set(END "\" />")
set(BEGIN "<ClCompile Include=\"")
string(REPLACE "/" "\\" ITEMS "${ITEMS}")
string(REPLACE "\" \\>" ${END} ITEMS "${ITEMS}")
string(REPLACE ".\\" "..\\" ITEMS "${ITEMS}")
string(REPLACE ";" "${END}
${BEGIN}" ITEMS "${ITEMS}")
file(WRITE ${MOTOPLUSPROJECT_DIR}/${name}.vcxproj
"<?xml version=\"1.0\" encoding=\"utf-8\"?>
<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">
<ItemGroup>
${BEGIN}${ITEMS}${END}
</ItemGroup>
</Project>
"
)

#Launching compilation and linking
add_custom_target(${name} ALL
SOURCES ${SRCS_} ${HEADERS_}
COMMAND ${MPBUILDER_PATH}
-c ${controller}
-p ${MOTOPLUSPROJECT_DIR}
-n ${name}${PROJECT_VERSION}
-I${MPBUILDER_DIR}/${controller}/inc
-l N
-d T
#-b ${CMAKE_SOURCE_DIR}/${name}/output
-o build)
endmacro(PROJECT_CONFIG)

#Adding support for the application on several controllers
project_config(MotoRos DX100)
project_config(MotoRos DX200)
project_config(MotoRos FS100)
project_config(MotoRos YRC1000)
project_config(MotoRos YRC1000u)