Skip to content

Fix define flags in CMakeLists.txt#33

Open
stefi07 wants to merge 2 commits into
jaredmales:devfrom
stefi07:patch-1
Open

Fix define flags in CMakeLists.txt#33
stefi07 wants to merge 2 commits into
jaredmales:devfrom
stefi07:patch-1

Conversation

@stefi07
Copy link
Copy Markdown

@stefi07 stefi07 commented Apr 28, 2026

Flags added with add_compile_definitions shouldn't have a -D, since that gets added automatically, but flags included in variables defined with set should, since they are used as is.

Flags added with `add_compile_definitions` shouldn't have a `-D`, since that gets added automatically, but flags included in variables defined with `set` should, since they are used as is.
Comment thread CMakeLists.txt Outdated
set(CMAKE_CXX_FLAGS "${MXLIB_CXXVERSION} ${MXLIB_OPTIMIZE} ${MXLIB_CXXFLAGS}")

set(MXLIB_PC_CFLAGS "${MXLIB_PC_CFLAGS} ${CMAKE_CXX_FLAGS} ${MXLIB_DEFINES}")
set(MXLIB_PC_CFLAGS "${MXLIB_PC_CFLAGS} ${CMAKE_CXX_FLAGS} -${MXLIB_DEFINES}")
Copy link
Copy Markdown
Owner

@jaredmales jaredmales May 3, 2026

Choose a reason for hiding this comment

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

what happens here if MXLIB_DEFINES has more than one thing in it?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

If MXLIB_DEFINES has multiple elements, this would break. Handling multiple elements would require iterating and prepending -D to each. I can define another variable to do that if MXLIB_DEFINES is likely to grow.

Comment thread CMakeLists.txt Outdated

#Don't let Eigen use openmp
add_compile_definitions(-DEIGEN_DONT_PARALLELIZE)
add_compile_definitions(DEIGEN_DONT_PARALLELIZE)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

should this keep the D?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No, it shouldn't.

Comment thread CMakeLists.txt Outdated
set(MXLIB_NVCCXX_FLAGS "${MXLIB_NVCCXX_FLAGS} -I${EIGEN3_INCLUDE_DIRS} ${EIGEN3_CFLAGS} ${EIGEN3_CFLAGS_OTHER}")

set(MXLIB_PC_CFLAGS "${MXLIB_PC_CFLAGS} -I${EIGEN3_INCLUDE_DIRS} ${EIGEN3_CFLAGS} ${EIGEN3_CFLAGS_OTHER} -DEIGEN_DONT_PARALLELIZE")
set(MXLIB_PC_CFLAGS "${MXLIB_PC_CFLAGS} -I${EIGEN3_INCLUDE_DIRS} ${EIGEN3_CFLAGS} ${EIGEN3_CFLAGS_OTHER} -DDEIGEN_DONT_PARALLELIZE")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

why the extra D?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Indeed there shouldn't be one.

Comment thread CMakeLists.txt Outdated
set(MXLIB_OPTIMIZE "-O3 --fast-math" CACHE STRING "mxlib optimization settings")

set(MXLIB_DEFINES "-D_XOPEN_SOURCE=700" CACHE STRING "mxlib compiler command line defines")
set(MXLIB_DEFINES "D_XOPEN_SOURCE=700" CACHE STRING "mxlib compiler command line defines")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

we don't need the - here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Actually we don't need the -D. It's manually added on line 365 for the flag definition and on line 360, add_compile_definitions adds its own automatically.

@stefi07
Copy link
Copy Markdown
Author

stefi07 commented May 5, 2026

I've made the fixes necessary based on your comments.

The complication here is due to the variables being used in two different contexts: as input to add_compile_definitions (which prepends its own -D) and as input to the compile flags lists that MagAOX needs (where the -D needs to be already prepended). It looks like in version 3.26 of CMake, any leading -Ds on items in COMPILE_DEFINITIONS are removed, so an alternative to the current changes is requiring that version and keeping all the -Ds.

@jaredmales
Copy link
Copy Markdown
Owner

yeah maintaining a fully specified pkgconfig file is a pain. I already implemented a bunch of such processors for other flags so I think we can add something that iterates and adds -D if we really need to.

According to ChatGPT requiring 3.26 will only be a problem on Ubuntu 22 and then only if we can't update the toolchain. So that is a fine workaround.

@jaredmales
Copy link
Copy Markdown
Owner

thanks for looking at this, btw

@stefi07
Copy link
Copy Markdown
Author

stefi07 commented May 8, 2026

Of course!

I tested the install on one of our Orins with the 3.26 requirement and it worked the same as for 3.24, so updating the requirement shouldn’t add any extra overhead for us if we end up stuck on U22. (As an aside, discussions are in progress with NSV to update us, but there isn’t a clear path yet).

So then we can close this PR unmerged and I’m happy to open another one to update the requirement. How does that sound to you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants