Skip to content
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

Make the monolith test a C++ binary. #711

Merged
merged 1 commit into from
Jan 21, 2018
Merged

Conversation

iphydf
Copy link
Member

@iphydf iphydf commented Jan 20, 2018

This way, developers compile toxcore, toxav, and toxencryptsave as C++ at
least once at home, reducing the likelyhood of running into travis
failures where we compile as C++ in the windows build.


This change is Reviewable

@iphydf iphydf added this to the v0.2.0 milestone Jan 20, 2018
@nurupo
Copy link
Member

nurupo commented Jan 21, 2018

This PR seems to have some unrelated changes in it.


Review status: 0 of 5 files reviewed at latest revision, 1 unresolved discussion.


CMakeLists.txt, line 464 at r1 (raw file):

if(BUILD_TOXAV)
  add_c_executable(auto_monolith_test
    auto_tests/monolith_test.cpp

Wouldn't this change make C++ compiler required for building toxav? This is a bit undesirable since it's not actually necessary for building toxav. For example, when building toxcore in Docker you generally want to install as few packages as necessary to save time and disk space.


Comments from Reviewable

@iphydf
Copy link
Member Author

iphydf commented Jan 21, 2018

Review status: 0 of 5 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


CMakeLists.txt, line 464 at r1 (raw file):

Previously, nurupo wrote…

Wouldn't this change make C++ compiler required for building toxav? This is a bit undesirable since it's not actually necessary for building toxav. For example, when building toxcore in Docker you generally want to install as few packages as necessary to save time and disk space.

As you have noted, cmake requires a C++ compiler regardless. I agree, it'll add a few seconds to the build, maybe up to 10 on a slow system/network, but adding more ifs around it adds maintenance cost for rare and negligible benefit (libstdc++ is 1.5M). We can reconsider if this actually becomes a problem.


Comments from Reviewable

@nurupo
Copy link
Member

nurupo commented Jan 21, 2018

Reviewed 6 of 6 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


CMakeLists.txt, line 464 at r1 (raw file):

Previously, iphydf wrote…

As you have noted, cmake requires a C++ compiler regardless. I agree, it'll add a few seconds to the build, maybe up to 10 on a slow system/network, but adding more ifs around it adds maintenance cost for rare and negligible benefit (libstdc++ is 1.5M). We can reconsider if this actually becomes a problem.

CMake requires C++ compiler regardless? I didn't know that. I only noted that this change will now make toxcore's cmake require C++ compiler, when before this change that wasn't the case. If CMake, and I'm not talking about toxcore's cmake setup but the actual CMake software, does indeed require C++ compiler for C projects, then alright. I was under the impression it didn't.


Comments from Reviewable

@nurupo
Copy link
Member

nurupo commented Jan 21, 2018

:lgtm_strong:


Review status: all files reviewed at latest revision, 1 unresolved discussion.


CMakeLists.txt, line 464 at r1 (raw file):

Previously, nurupo wrote…

CMake requires C++ compiler regardless? I didn't know that. I only noted that this change will now make toxcore's cmake require C++ compiler, when before this change that wasn't the case. If CMake, and I'm not talking about toxcore's cmake setup but the actual CMake software, does indeed require C++ compiler for C projects, then alright. I was under the impression it didn't.

Yeah, you are right, CMake does require C++ compiler for C projects, just did a fast test in a docker container:

-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:19 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "/root/c-toxcore/build/CMakeFiles/CMakeOutput.log".
See also "/root/c-toxcore/build/CMakeFiles/CMakeError.log".

Comments from Reviewable

@nurupo
Copy link
Member

nurupo commented Jan 21, 2018

:lgtm_cancel:


Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful.


CMakeLists.txt, line 464 at r1 (raw file):

Previously, nurupo wrote…

Yeah, you are right, CMake does require C++ compiler for C projects, just did a fast test in a docker container:

-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is unknown
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:19 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "/root/c-toxcore/build/CMakeFiles/CMakeOutput.log".
See also "/root/c-toxcore/build/CMakeFiles/CMakeError.log".

Wait a moment, C++ compiler is required only because we don't specify the programming lanauge of the toxcore project in

project(toxcore)

If you set it to

project(toxcore C)

then it doesn't look for C++ compiler. I wonder if there is a way to add a language on a condition, like we have this COMPILE_AS_CXX.


Comments from Reviewable

@nurupo
Copy link
Member

nurupo commented Jan 21, 2018

Review status: all files reviewed at latest revision, 2 unresolved discussions.


CMakeLists.txt, line 463 at r1 (raw file):

add_c_executable

Adding CXX executable using add_c_executable function. Perhaps the function doesn't live up to its name and the name should be changed?


CMakeLists.txt, line 464 at r1 (raw file):

Previously, nurupo wrote…

Wait a moment, C++ compiler is required only because we don't specify the programming lanauge of the toxcore project in

project(toxcore)

If you set it to

project(toxcore C)

then it doesn't look for C++ compiler. I wonder if there is a way to add a language on a condition, like we have this COMPILE_AS_CXX.

Found it. You can optionally enable C++. So we could have toxcore as a C project by default but enable C++ if COMPILE_AS_CXX is specified.

project(toxcore C)

if(COMPILE_AS_CXX)
    language_enable(CXX)
endif()

You will also need to put a if(COMPILE_AS_CXX) around add_cxx_flag().

So, what do you say about this (about making the C++ compiler optional)? Should probably be a separate PR, so I will let this go through.


Comments from Reviewable

@iphydf
Copy link
Member Author

iphydf commented Jan 21, 2018

Review status: 4 of 6 files reviewed at latest revision, 2 unresolved discussions.


CMakeLists.txt, line 463 at r1 (raw file):

Previously, nurupo wrote…

add_c_executable

Adding CXX executable using add_c_executable function. Perhaps the function doesn't live up to its name and the name should be changed?

Done.


CMakeLists.txt, line 464 at r1 (raw file):

Previously, nurupo wrote…

Found it. You can optionally enable C++. So we could have toxcore as a C project by default but enable C++ if COMPILE_AS_CXX is specified.

project(toxcore C)

if(COMPILE_AS_CXX)
    language_enable(CXX)
endif()

You will also need to put a if(COMPILE_AS_CXX) around add_cxx_flag().

So, what do you say about this (about making the C++ compiler optional)? Should probably be a separate PR, so I will let this go through.

Maybe separate PR.


Comments from Reviewable

@nurupo
Copy link
Member

nurupo commented Jan 21, 2018

:lgtm_strong:


Reviewed 2 of 2 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved, some commit checks failed.


Comments from Reviewable

This way, developers compile toxcore, toxav, and toxencryptsave as C++ at
least once at home, reducing the likelyhood of running into travis
failures where we compile as C++ in the windows build.
@iphydf iphydf merged commit 033965b into TokTok:master Jan 21, 2018
@iphydf iphydf deleted the cxx-monolith branch January 21, 2018 21:17
This pull request was closed.
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