-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake support to build ACE+TAO including IDL targets #177
base: master
Are you sure you want to change the base?
Conversation
templates/cmake.mpd
Outdated
<%else%> | ||
<%if(custom_types)%> | ||
add_library(${PROJECT_TARGET_<%uc(normalize(project_name))%>} OBJECT) | ||
<%endif%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do and when does it come into play?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things.
First, declaring a compilable target is (currently) required because MPC (currently) emits CMake code that sets several properties of the target ${PROJECT_TARGET_<%uc(normalize(project_name))%>}
, including via set_target_properties()
, target_compile_definitions()
, and target_link_directories()
. And currently, no target is declared for custom_types with no library or executable (e.g. IDL). So declaring an object library for custom targets was the smallest change that allowed me to build ACE+TAO. However, I'm not sure if that's "correct" as I don't know the full scope of what custom_types
are.
- Instead of declaring an object library target, you could conceivably add logic to disable setting those properties for
custom_types
, but like I said, I don't know whatcustom_types
could be. Perhaps there arecustom_types
whose output you'd want to compile & link into a library? (I collect my IDL outputs into static or object libraries.)
Second: if tao_idl
outputs CPP/H files into the source directory (where all TAO projects expect them), then it's necessary to add those files to some target in the same directory as the CMakeLists.txt that calls tao_idl
. (In this case, for simplicity IDL_FILES_TARGET_SOURCES()
adds them to the main target of the very file that calls it). If you don't, then CMake does not detect that a command (tao_idl
) exists to resolve dependencies on them, and CMake will report missing dependency errors for projects that use them. This prominently happens for AnyTypeCode
and PortableServer
- Conceivably,
IDL_FILES_TARGET_SOURCES()
could declare new object library targets for each IDL file, perhaps based on the IDL filename without an extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to recommendations or edits for both points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it require the project that is only a custom_type to create a library? If not, then I'm ok with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure entirely what you mean.
Currently, that custom_types
object library target is only emitted if the project did not have an executable or (shared or static) library. Do you know whether custom_types
projects can ever have those?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm asking, what does this line do for the project? In MPC, custom_type only projects do not create libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexchandel it may help to define these terms. See MPC's README and html docs for more details.
custom_types
is a data structure that can be used in MPC templates. It contains the details of the Define_Custom
sections of the input. Typically these are "custom build steps" that run commands (that are not compiling/linking) to generate source files or inputs to other custom build steps.
custom_only
is a kind of MPC project that MSVS calls "Utility" -- it doesn't produce object files, a library or an executable, only runs custom build steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitza-oci This helps. Important question: is it possible to have a custom_types
project that is not custom_only
? No MPC files in ACE/TAO result in CMakeLists project that has a custom_types
plus any other targets (exename
, sharedname
, or staticname
) that I found, but is it possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ocielliottc I've changed the MPC implementation so that custom_types no longer require an object library (and rebased/squashed commits).
The new IDL macro implementation creates a subtarget for individual IDL files, and adds them to a project target (an exe or library) if one exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to have a custom_types project that is not custom_only
If "having a custom_types project" means any project that includes custom generation targets (those files types that are made known to MPC via Define_Custom), then yes this is done quite often in projects that are not custom_only (that is, projects that produce a library or executable).
I've updated my example implementation to use pure CMake, using a
|
We should have a github action with cmake usage in the mpc project, currently only in ace/tao |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a cmake github CI action (see ACE/TAO master) in order to make sure changes here don't break building ACE/TAO
Just ping me and I'll rebase the PR as needed. Could someone explain why |
I may need help with this. Are you referring to this workflow? |
Building the Windows example currently fails to link, with this mystery:
…
Done Building Project "C:\Users\Dev\Git\test-cmake-acetao\build\opt\ACE_wrappers\TAO\orbsvcs\orbsvcs\TAO_CosNotification_Serv.vcxproj" (default targets).
PrepareForBuild:
Creating directory "TrivialTest.dir\Debug\".
Creating directory "C:\Users\Dev\Git\test-cmake-acetao\build\Debug\".
Creating directory "TrivialTest.dir\Debug\TrivialTest.tlog\".
InitializeBuildStatus:
Creating "TrivialTest.dir\Debug\TrivialTest.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
Building Custom Rule C:/Users/Dev/Git/test-cmake-acetao/CMakeLists.txt
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\CL.exe /c /I"C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers" /I"C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\TAO" /I"C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\TAO\orbsvcs" /Zi /nologo /W1 /WX- /diagnostics:column /Od /Ob0 /D _MBCS /D WIN32 /D _WINDOWS /D "MPC_LIB_MODIFIER=\"d\"" /D TAO_HAS_VALUETYPE_OUT_INDIRECTION /D TAO_HAS_TYPED_EVENT_CHANNEL /D "CMAKE_INTDIR=\"Debug\"" /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"TrivialTest.dir\Debug\\" /Fd"TrivialTest.dir\Debug\vc142.pdb" /external:W1 /Gd /TP /errorReport:queue "C:\Users\Dev\Git\test-cmake-acetao\main.cpp"
main.cpp
Link:
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\Dev\Git\test-cmake-acetao\build\Debug\TrivialTest.exe" /INCREMENTAL /ILK:"TrivialTest.dir\Debug\TrivialTest.ilk" /NOLOGO "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\ACEd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\ACE_ETCLd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\ACE_ETCL_Parserd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAOd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_AnyTypeCoded.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CodecFactoryd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CosConcurrencyd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CosEventd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CosEvent_Servd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CosEvent_Skeld.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CosNamingd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CosNaming_Servd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CosNaming_Skeld.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CosNotificationd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CosNotification_Servd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_CosNotification_Skeld.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_DynamicAnyd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_DynamicInterfaced.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_ETCLd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_IFR_Clientd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_IORTabled.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_Messagingd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_PId.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_PortableServerd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_Svc_Utilsd.lib" "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\lib\TAO_Valuetyped.lib" iphlpapi.lib TAO_IFR_Clientd.lib TAO_DynamicInterfaced.lib TAO_IORTabled.lib TAO_CosNaming_Skeld.lib TAO_CosNamingd.lib ACE_ETCL_Parserd.lib TAO_ETCLd.lib TAO_DynamicAnyd.lib TAO_CosNotification_Skeld.lib TAO_Svc_Utilsd.lib TAO_CosEvent_Skeld.lib TAO_CosNotificationd.lib TAO_CosEventd.lib TAO_Messagingd.lib ACE_ETCLd.lib TAO_PId.lib TAO_Valuetyped.lib TAO_CodecFactoryd.lib TAO_PortableServerd.lib TAO_AnyTypeCoded.lib TAOd.lib ACEd.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"C:/Users/Dev/Git/test-cmake-acetao/build/Debug/TrivialTest.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Users/Dev/Git/test-cmake-acetao/build/Debug/TrivialTest.lib" /MACHINE:X64 /machine:x64 TrivialTest.dir\Debug\main.obj
LINK : fatal error LNK1104: cannot open file 'TAO_IFR_Clientd.lib' [C:\Users\Dev\Git\test-cmake-acetao\build\TrivialTest.vcxproj]
Done Building Project "C:\Users\Dev\Git\test-cmake-acetao\build\TrivialTest.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\Users\Dev\Git\test-cmake-acetao\build\ALL_BUILD.vcxproj" (default targets) -- FAILED.
Build FAILED.
"C:\Users\Dev\Git\test-cmake-acetao\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\Dev\Git\test-cmake-acetao\build\TrivialTest.vcxproj" (default target) (3) ->
"C:\Users\Dev\Git\test-cmake-acetao\build\opt\ACE_wrappers\TAO\tao\CodecFactory\TAO_CodecFactory.vcxproj" (default target) (13) ->
(CustomBuild target) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): warning MSB8065: Custom build for item "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\TAO\tao\CodecFactory\IOP_Codec.pidl" succeeded, but specified output "c:\users\dev\git\test-cmake-acetao\build\opt\ace_wrappers\tao\tao\codecfactory" has not been created. This may cause incremental build to work incorrectly. [C:\Users\Dev\Git\test-cmake-acetao\build\opt\ACE_wrappers\TAO\tao\CodecFactory\TAO_CodecFactory.vcxproj]
"C:\Users\Dev\Git\test-cmake-acetao\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\Dev\Git\test-cmake-acetao\build\TrivialTest.vcxproj" (default target) (3) ->
"C:\Users\Dev\Git\test-cmake-acetao\build\opt\ACE_wrappers\TAO\orbsvcs\orbsvcs\TAO_CosEvent_Serv.vcxproj" (default target) (16) ->
"C:\Users\Dev\Git\test-cmake-acetao\build\opt\ACE_wrappers\TAO\tao\IFR_Client\TAO_IFR_Client.vcxproj" (default target) (25) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): warning MSB8065: Custom build for item "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\TAO\tao\IFR_Client\IFR_Base.pidl" succeeded, but specified output "c:\users\dev\git\test-cmake-acetao\build\opt\ace_wrappers\tao\tao\ifr_client" has not been created. This may cause incremental build to work incorrectly. [C:\Users\Dev\Git\test-cmake-acetao\build\opt\ACE_wrappers\TAO\tao\IFR_Client\TAO_IFR_Client.vcxproj]
"C:\Users\Dev\Git\test-cmake-acetao\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\Dev\Git\test-cmake-acetao\build\TrivialTest.vcxproj" (default target) (3) ->
"C:\Users\Dev\Git\test-cmake-acetao\build\opt\ACE_wrappers\TAO\orbsvcs\orbsvcs\TAO_CosNaming_Serv.vcxproj" (default target) (26) ->
"C:\Users\Dev\Git\test-cmake-acetao\build\opt\ACE_wrappers\TAO\tao\IORTable\TAO_IORTable.vcxproj" (default target) (28) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): warning MSB8065: Custom build for item "C:\Users\Dev\Git\test-cmake-acetao\opt\ACE_wrappers\TAO\tao\IORTable\IORTable.pidl" succeeded, but specified output "c:\users\dev\git\test-cmake-acetao\build\opt\ace_wrappers\tao\tao\iortable" has not been created. This may cause incremental build to work incorrectly. [C:\Users\Dev\Git\test-cmake-acetao\build\opt\ACE_wrappers\TAO\tao\IORTable\TAO_IORTable.vcxproj]
"C:\Users\Dev\Git\test-cmake-acetao\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\Dev\Git\test-cmake-acetao\build\TrivialTest.vcxproj" (default target) (3) ->
(Link target) ->
LINK : fatal error LNK1104: cannot open file 'TAO_IFR_Clientd.lib' [C:\Users\Dev\Git\test-cmake-acetao\build\TrivialTest.vcxproj]
3 Warning(s)
1 Error(s)
No idea why. It could be a coincidence, but CMake generation on unix also prints a couple warnings about
|
One thing to resolve on Windows / MSVC. Three TAO IDL projects (`CodecFactory`, `IFR_Client`, and `IORTable`) repeatedly regenerate their sources and rebuild on every `cmake --build` invocation, each with a similar warning referencing a nonexistent target:
…
ACE_ETCL.vcxproj -> C:\Users\Dev\Git\vplk\opt\ACE_wrappers\lib\ACE_ETCLd.dll
ACE_ETCL_Parser.vcxproj -> C:\Users\Dev\Git\vplk\opt\ACE_wrappers\lib\ACE_ETCL_Parserd.dll
Generating C:/Users/Dev/Git/vplk/opt/ACE_wrappers/TAO/tao/CodecFactory/IOP_CodecC.h, ., C:/Users/Dev/Git/vplk/opt/ACE_wrappers/TAO/tao/CodecFactory/IOP_CodecS.h, C:/Users/Dev/Git/vplk/opt/ACE_wrappers/TAO/tao/CodecFactory/IOP_CodecA.h, C:/Users/Dev/Git/vplk/opt/ACE_wrappers/TAO/tao/CodecFactory/IOP_CodecC.cpp tao-idli_4xRhFS.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): warning MSB8065: Custom build for item "C:\Users\Dev\Git\vplk\opt\ACE_wrappers\TAO\tao\CodecFactory\IOP_Codec.pidl" succeeded, but specified output "c:\users\dev\git\vplk\build\opt\ace_wrappers\tao\tao\codecfactory" has not been created. This may cause incremental build to work incorrectly. [C:\Users\Dev\Git\vplk\build\opt\ACE_wrappers\TAO\tao\CodecFactory\TAO_CodecFactory.vcxproj]
CDR_Encaps_Codec.cpp
CodecFactory.cpp
CodecFactory_impl.cpp
IOP_CodecC.cpp
IOP_Codec_includeC.cpp
Generating Code...
TAO_CodecFactory.vcxproj -> C:\Users\Dev\Git\vplk\opt\ACE_wrappers\lib\TAO_CodecFactoryd.dll
TAO_CosEvent_Skel.vcxproj -> C:\Users\Dev\Git\vplk\opt\ACE_wrappers\lib\TAO_CosEvent_Skeld.dll
… What's different about these three libraries? |
Yes |
They are not empty in static builds. It seems like they were added to work around some platform limit on the size (in objects or symbols or ??) of archive libraries on that platform. It is reasonable to consider removing that workaround. But that's not part of the MPC repository - please create an issue or PR in ACE_TAO. |
@mitza-oci Ok, I will also try to edit the CMake generation to account for them then. My goal is to provide retroactive support for valid MPC files & ACE+TAO versions (hence I included checks for post-7.0.11 ACE+TAO in |
dfc892d
to
773e158
Compare
How does one enable SSL or IPv6 when generating from MPC? I see that the MPC files in
|
You can either modify
or You can add them to your MPC command line: The |
Do not generate target properties if custom_only. Add headers and inline files to compiled targets. Supply correct target names for linking libraries.
I rewrote the commits to fix a bug with linking and installation, and another with out-of-source builds. I've also updated my reference implementation of With the reference implementation (and its |
Where in the ACE+TAO MPC configuration do you define the version of the C++ standard that the ACE+TAO source currently requires? I currently have to manually add C++11: target_compile_features(ACE PUBLIC cxx_std_11)
target_compile_features(TAO PUBLIC cxx_std_11) |
I'm don't think there's a place where MPC itself is concerned with that. As far as I know it's assumed until checked here (Note: it was C++11 until recently). These macros come from the platform config files like this one for |
@iguessthislldo I would argue that the minimum C++ standard required by the source is something the MPC project files should be concerned with and declare, as the compiler must be told by the build system which version to use. MPC shouldn't just assume the compiler will use the latest standard it can (and compilers do not generally, as each C++ standard introduces many breaking changes). And after all, 7.0.12's source will now error if the standard less than C++14. So the MPC project file should declare a minimum standard for the source, so users and build systems don't have to do this manually. |
MPC is not assuming that.
This is not what MPC does. MPC generates projects and has a number of mechanisms for customizing those projects, it's not a complete configuration system like CMake. |
Combined with CMake scripts in this example, this PR enables building ACE+TAO with IDL generation (following #164). The example links two dozen different ACE+TAO libraries including some orbsvcs with no manual hard-coding.
I made minimal modifications, doing most in
IDL_FILES_TARGET_SOURCES()
.Key changes:
target_sources()
silently failed when applied to targets fromadd_custom_command()
. This causes sources generated from IDL into different directories to fail to be detected by CMake for dependency resolution purposes.custom_types
(e.g. AnyTypeCode_Idl) are emitted as object library targets. They have to be something, as MPC sets several properties of the named target, includingset_target_properties()
,target_compile_definitions()
, andtarget_link_directories()
, which error otherwise. Also, the emittedIDL_FILES_TARGET_SOURCES()
macro currently adds all generated sources to the target, to ensure CMake interprets them as being in the source directory for dependency purposes (won't happen otherwise, even though I tell CMake absolute paths). Note that these IDL object library targets are purely bookkeeping, and are not actually built.PRIVATE
, or else the following error occurs:Considerations that went into this:
INTERFACE
properties, while we setPUBLIC
andPRIVATE
properties.add_custom_target()
, but that would require disabling thetarget_compile_definitions()
andtarget_link_directories()
forcustom_only
targets (which is doable) and also making the macro callsPRIVATE
. It has other issues too.IDL_FILES_TARGET_SOURCES()
calculates absolute paths for CMake, but preserves passing relative paths totao_idl
as requiredConsiderations before merging
Before merging, I'd like to know if it's possible to fix the
TAO_IDL_BE_VIS_*
issue. (The targets are completely empty, so CMake complains. I justcomment outprogrammatically delete those 8 lines of$TAO_ROOT/TAO_IDL/CMakeLists.txt
. See linked example.)I'm also wondering if it's possible to generate the three CMake scripts in the appropriate area, maybe when
tao_idl
is defined. Or potentially be emitted into aConfigAceTao.cmake
module.