Skip to content

Switching to CMake;#14

Open
raue wants to merge 2 commits into
OxfordTechnicalSolutions:masterfrom
raue:feature/cmake
Open

Switching to CMake;#14
raue wants to merge 2 commits into
OxfordTechnicalSolutions:masterfrom
raue:feature/cmake

Conversation

@raue
Copy link
Copy Markdown

@raue raue commented Feb 12, 2024

switching to cmake in order to focus on supported OSs

Comment thread CMakeLists.txt Outdated
message(FATAL_ERROR "${CMAKE_SYSTEM_NAME} OS detected - currently not supported - EXIT")
endif()

include_directories(nav)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I suggest using target_include_directories() instead.

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.

ok.
would lead to something like this, or?
cmake_minimum_required(VERSION 3.19.0)

project(NCOM2CSV)

if(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
message("Apple OS (Darwin) detected")
elseif(${CMAKE_SYSTEM_NAME} MATCHES Linux)
message("Linux OS detected")
else()
message(FATAL_ERROR "${CMAKE_SYSTEM_NAME} OS detected - currently not supported - EXIT")
endif()

set(SOURCES nav/NComRxC.c example/NcomToCsv.c)
add_executable(ncom2csv ${SOURCES})
target_include_directories(ncom2csv PRIVATE nav)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes, looks like the way to go.

Comment thread CMakeLists.txt
endif()

include_directories(nav)
set(SOURCES nav/NComRxC.c example/NcomToCsv.c)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I suggest listing header files as well for the sake of completeness and explicitness. Despite this is not really necessary to build the code, some IDEs benefit from that.

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.

well, pointing to a directory instead of single files would keep the script - slightly - leaner and easier to maintain. So I'd propose just to mention the include directory by using the suggested target_include_directories().

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Any of the suggested approaches will allow to build the code. This is more about convenience with regards to personal habbits and tools used by active contributors. So, they are the ones to decide.

Basically, the trade-off is whether one wants less writing CMakeLists or have more robust setup with regards to tooling like IDEs and Git in terms of active switching between branches.

Up 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